Skip to content

Toolset: Enable „AND“ connection in parametric search when using taxonomies

I had to create a parametric search but encountered the problem that when I combine multiple taxonomies, there is always an „OR“ connection between them regardless of my settings in the view. Put this snippet in the functions.php to change this behavior. Simply change the ID to the according form you use (the view)-id.

/**
 * New custom code snippet (replace this with snippet description).
 */

toolset_snippet_security_check() or die( 'Direct access is not allowed' );

// Put the code of your snippet below this comment.

add_filter( 'wpv_filter_query', 'func_change_or_caluse', 101, 3 );
function func_change_or_caluse( $view_args, $view_settings, $view_id ){
 
/*change to your view ID*/
    if ($view_id == 8365 ) { 
       
      if(count($view_args['meta_query']) > 0) {
        		foreach((array)$view_args['meta_query'] as $k=>$v):
           			           
           			if(isset($v['relation'])) {
                      $view_args['meta_query'][$k]['relation'] = 'AND';
                    }
            
        		endforeach;
        }
 
        
      
    }
 
    return $view_args;
}

You can find more Toolset tips and tricks on this page

Dieser Beitrag hat 0 Kommentare

Schreibe einen Kommentar

Deine E-Mail wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

An den Anfang scrollen