Skip Navigation

[Escalated to 2nd Tier] View that uses custom fields filters also in multiple taxonomies

This support ticket is created 3 years, 11 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.

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 3 years, 11 months ago.

Assisted by: Waqar.

Author
Posts
#1885835
Schermata 2020-12-24 alle 10.42.23.png
Schermata 2020-12-24 alle 10.41.52.png

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"

#1886039

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