Skip Navigation

[Resolved] Parametric Search Page OR operator not AND

This support ticket is created 3 years, 4 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 IntegrisDesign 3 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#2158817

Tell us what you are trying to do? Change the operator from AND to OR

Is there any documentation that you are following? NONE - only saw a 2015 post

Is there a similar example that we can see? The link below. Probably something easy.

What is the link to your site? hidden link

#2159219

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

As I understand - you build a parametric search but for instance for the checkboxes field "Residential Communities" you want to apply "AND" clause rather "OR" when multiple checkboxes selected by user - correct?

And you want to apply this for all the checkboxes fitlers - correct? If yes:

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) 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.

#2159657

Minesh
Supporter

Languages: English (English )

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

I've added the following code to "Custom Code" section offered by Toolset:
=> hidden link

function func_adjust_filter_clause_to_or( $query_args ,$view_settings, $view_id ) {
    global $post;
     
    if ( $view_id == 4259 ) {
        
      
		if(isset($query_args['meta_query'])) {
        		$query_args['meta_query']['relation'] = "OR";
        }
		 
    }
    return $query_args;
}
add_filter( 'wpv_filter_query', 'func_adjust_filter_clause_to_or', 10, 3);

Can you please confirm it works at your end as well.

More info:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/#adding-custom-php-code-using-toolset
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

#2161701

Minesh
Supporter

Languages: English (English )

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

Can you please confirm the solution I shared help you to resolve your issue.

#2163169

My issue is resolved now. Thank you!