The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Advanced Filtering


This Discussion is public



I need some advice about the following:

I've created a view together with a search form on one page. The search form contains two fields: Color and Size. Initially, I made both fields mandatory and filtering works fine.

However, I want to make both fields optional. This means, when nothing is filled in, all entries are shown. When only the Color field is filled in, all entries with the same Color are shown and the Size field is not relevant. When only the Size field is filled in, all entries with the same Size are shown and the Color field is not relevant. When the Color field and Size field are filled in, all entries with the same Color and the same Size are shown.

How can this be achieved?

Thanks in advance.



You should probably hook into

With this hook, you can change the view parameters for filtering.

You may also need to access global $_POST to see which parameters are populated.

Hi Eric,
The filter should work without any changes in your view filters. If the filter value is empty, the corresponding filter in the View will be ignored. If you want to be sure, you can remove blank filter values in the search URL that you construct in your search form. This will also make the search URL cleaner. More info here -

Thank you all!

I noticed that I've forgotton to mention something else in my topic.

Filtering works fine. However, I also calculate totals based on these filters. This works fine as long as both search fields are filled in. If one or both field are not filled in, the totals are wrong.

This is one of the lines in the view for calculating totals:

[frm-stats id=693 type=total thousands_sep="." decimal=2 dec_point="," 690=[get param="BTW"] 701=[get param="EI"]]

When param BTW or param EI is not filled in, the values are wrong. I think in that case it should work the same as by filtering.Ignoringm but counting.

Any suggestions?


Hi Eric,
Here is a custom shortcode specific to your calculation. Feel free to customize it or make it general for all cases.


add_shortcode( 'my_stats', 'my_stats' );
function my_stats( $atts ) {
if($_GET['BTW']) {
$atts['690'] = $_GET['BTW'];
if($_GET['EI']) {
$atts['701'] = $_GET['EI'];
return FrmProStatisticsController::stats_shortcode($atts);


The code checks for URL param and only add it as a filter to stats function if param exists.
You can add the code using Snippet plugin (preferred) or by adding to functions.php.

Once code is added, you can use the shortcode like below
[my_stats id=693 type=total thousands_sep="." decimal=2 dec_point=","]

Discussion closed.