Problem:
The issue here is that the user wanted their custom query filter to function like an OR query instead of the default AND..
Solution:
Previously you were allowed to change the field comparison logic from AND to OR and vice versa but it got broken somehow in a recent update.
To work around this you're going to have to construct the query manually using the views hook. Add the following to your Toolset Custom Code section and it should help to resolve the issue.
The Toolset custom codes can be found at Toolset -> Settings -> Custom Code
add_filter( 'wpv_filter_query', 'filter_by_multiple_fields', 10, 3 ); function filter_by_multiple_fields( $query, $settings, $view_id ) { if ( $view_id == 1234) { $query['meta_query'] = array( 'relation' => 'OR', array( 'key' => 'color', 'value' => '1', 'compare' => '=', ), array( 'key' => 'price', 'value' => '1', 'compare' => '=', ), ); } return $query; }
Now replace the 1234 with the ID of your view and then replace color and price with the slugs of the field that you are doing the query on. Remember to add the wpcf- prefix to the types custom fields slugs.
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.
Our next available supporter will start replying to tickets in about 5.27 hours from now. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
This topic contains 2 replies, has 2 voices.
Last updated by 3 years, 5 months ago.
Assisted by: Shane.