Skip Navigation

[Resolved] Advanced filters not working

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 3 replies, has 2 voices.

Last updated by Minesh 1 year, 10 months ago.

Assisted by: Minesh.

Author
Posts
#2379937

I am trying to: load a filtered view based on more than one attribute

Link to a page where the issue can be seen: hidden link

I expected to see: only posts matching the filter

Instead, I got: all posts even those not matching the filter

Please see this video https : // jumpshare . com /v/LmGrGbFmJymz2FCtHyA9 for information

#2380103

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

It seems you want to apply "AND" clause between the checkboxes option you select for "Topics" taxonomy.
=> hidden link

I've added the following filter code to "Custom Code" section offered by Toolset:

add_filter( 'wpv_filter_query', 'func_filter_by_taxonomy_terms_and_clause', 10, 3 );
function func_filter_by_taxonomy_terms_and_clause( $query, $view_settings, $views_id ) {
    if ( $views_id == 2019 ) {
       
      if(isset($_GET['wpv-post_tag']) and !empty($_GET['wpv-post_tag']) ){
        	$tax_array = array('relation'=>'AND');
            foreach($_GET['wpv-post_tag'] as $k=>$v):
        		$tax_query_array[] = array('taxonomy'=>'post_tag','field'=>'slug','terms'=>$v,'operator'=>'IN');
        	endforeach;
        	unset($query['tax_query']);
        	$query['tax_query'] = array($tax_query_array);
      }
     
         
    }
    return $query;
}

Could you please check now if it works as expected:
- hidden link

#2380493

Yes it is functioning like it should be now! Thanks!

But it looks like the layout on that view is now broken hidden link and overlapping the content box that it is inside of?

#2381309

Minesh
Supporter

Languages: English (English )

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

I do not experience the same, I tried to filter the view with terms "Activism" and "HBCU" I can see it filters the result correctly.

Please check the following screenshot:
- hidden link

Do you still experience the issue?

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.