Glad that you've been making progress.
> One last question, just to consider for future optimizations. Would it be possible to join both views with functional filters? Is there documentation of someone trying to do something similar? I don't want to do it right now, but if possible I'd like to consider it for the future
- For programmatically filtering the view's results, you can use the 'wpv_filter_query' filter:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
And yes, you can use the same filtering function to target multiple views, by checking for the multiple target view IDs.
For example, suppose your target view IDs are '123', '456', and '789'. The custom filtering function's structure will look like this:
add_filter( 'wpv_filter_query', 'custom_filter_func', 1000 , 3 );
function custom_filter_func( $query_args, $view_settings ) {
// target view IDs
$view_ids_array = array(123, 456, 789);
// check if not in the admin area and the view is one of the target views
if ( !is_admin() && isset($view_settings['view_id']) && in_array($view_settings['view_id'], $view_ids_array) ) {
// do custom processing
}
return $query_args;
}
> By the way I have also noticed that the query filters are changed to AND mode when there is a front-end filter. So if the previous Query filters were exclusive, the view will always show that no results were found. It would be great to be able to set query filters in OR mode and have the filters selected by the user be in AND mode
- To change the relations operator between the multiple custom fields filter from "AND" to "OR", you can again use the "wpv_filter_query" filter:
add_filter( 'wpv_filter_query', 'wpv_filter_query_func', 1000 , 3 );
function wpv_filter_query_func( $query_args, $view_settings ) {
// process if specific view
if ( ( isset($view_settings['view_id']) && $view_settings['view_id'] == 1234) ) {
if( !empty($query_args['meta_query']) ) {
$query_args['meta_query']['relation'] = 'OR';
}
}
return $query_args;
}
Note: Please replace '1234' with the actual ID of your target view.
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 the active theme's "functions.php" file.
> The conflict happens only when one tries to apply the same filter on the backend and front end at the same time.
- Your observation is correct. You can either set a static/fixed query filter in the view's 'Query Filter' section or let it be controlled through the frontend search field filters. But, it is not possible to have both at the same time for the custom fields or taxonomies.