I have a website with many taxonomies
City
Type
Event Type
Custom Tag
...
I have a view that filters a taxonomy with the CITY Taxonomy
Example:
- City
- Type
With AND Relation
I would also add search filters for custom fields but it doesn't work.
Filters are like:
- Pool
- Spa
- Terrace
Example: (City = Rome AND Type = Club) AND (Filter1 OR Filter2 OR Filter3... )
While adding these filters toolset show me an advice:
"I tuoi filtri campo personalizzato stanno utilizzando un tipo di relazione interna "OR" e la ricerca personalizzata dipendente per quei filtri che richiedono relazioni "AND"."
Translated in "Your custom fields filters are using an OR relation and the dependent custom search for that filters needs AND relation"
Hi,
Thank you for contacting us and I'd be happy to assist.
I've performed some tests on my website, but couldn't see the advice/message that is shown in your screenshot.
However, I did notice that the "OR" relationship selection doesn't work and the view always seem to use the "AND" relation.
( for both the custom fields and the taxonomy filters )
I've shared these findings with the concerned team for further review and will keep you updated through this ticket.
For now, a workaround can be to manually change the relation to "OR" for the custom fields filters, using the "wpv_filter_query" hook.
( ref: https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query )
For example:
add_filter( 'wpv_filter_query', 'filter_view_meta_relation', 1000 , 3 );
function filter_view_meta_relation( $query_args, $view_settings ) {
if ( !is_admin() && ( isset($view_settings['view_id']) && $view_settings['view_id'] ==1234) ) {
$query_args['meta_query']['relation'] = 'OR';
}
return $query_args;
}
Please replace "1234" with your actual View's ID.
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through active theme's "functions.php" file.
regards,
Waqar