Skip Navigation

[Resolved] taxonomy checkboxes filter issue

This support ticket is created 2 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by Minesh 2 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#2333935

Tell us what you are trying to do?

when no taxonomy filter checkboxes re checked dont show any results.

Is there any documentation that you are following?

no

Is there a similar example that we can see?

no

What is the link to your site?

hidden link
you can see that when you uncheck all four map categories it then shows all posts. It should show none.

#2334077

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset supporter.

Can you please try to add the following filter code to "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

add_filter( 'wpv_filter_query', 'func_filter_by_default_no_results', 10, 3 );
function func_filter_by_default_no_results( $query, $view_settings, $views_id ) {
    if ( $views_id == 922) {

        if(defined('DOING_AJAX') && DOING_AJAX){
   
            foreach($_REQUEST['search']['dps_general'] as $k=>$v):
                if( !isset($v['name']) and !isset($v['value']) ){
                   $query['post__in'] = array(0);
                }
            endforeach;
        
 
        }
    return $query;
}
#2334523

Minesh,

Thank you for this however it doesnt seem to work. The snippet was throwing an error so I had added an extra }; to the end of the script which resolved the error. The code wouldnt work for me either way.

The code is currently installed as you provided it if you want to take a look.... hidden link

#2335011

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share admin acce3ss details and let me see whats going wrong with your setup.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2335727

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've added the following code to the "custom code" section:

add_filter('wpv_filter_query', 'func_filter_by_default_no_results', 10, 3 );
function func_filter_by_default_no_results( $query, $view_settings, $views_id ) {
 
    if ( $views_id == 922) {
 		
        if(defined('DOING_AJAX') && DOING_AJAX){
          $tax_args = $query['tax_query'];
         
       		$flag = false;
            foreach($tax_args as $k=>$v):
                if(isset($v['taxonomy']) and $v['taxonomy']=='location-brand'){
                 	$flag = true;
                }
            endforeach;
          
          	if(!$flag){
              	$query['post__in'] = array(0);
            } 
        }		
    }
    return $query;
    }

I see you must be using some custom JS for your category filter and as per the view's setting "Show only available options for each input" when you try to uncheck the last checkbox the taxonomy filter box is gone.

To offer taxonomy filter even there is no results you should switch the view's settings to "Always show all values for inputs".

I can see when last checkbox is checked the view returns 0 results but its due to some custom JS code added by you for your taxonomy filter as soon as you click it the filter box disappears as well as map does not reload because you should add specific location in no result found area and add a marker to display by default when there is no posts to display.