Hello,
I have the following site with Toolset and a Library Search functionality: hidden link
I would like to add the following modifications, but nor sure how to do it:
1. If, for example, 2 years are selected (2019 & 2018, and 1 document type (Research protocol), desired results would be all research protocols from 2019 and 2018
basically : (2019 or 2018) AND Research protocol
2. Or another example
- If, for example, 2 years are selected (2019 & 2018, and 2 document type (Research protocol, Research report),
(2019 or 2018) AND (Research protocol OR Research report)
.. so basically all Research protocol and Research reports from 2019 and 2018.
Please let us know how can we implement these queries?
The problem here is that we may not be able to get this logic working exactly as you would want it. Currently we can only do an AND across multiple custom fields.
I've made some modifications to the code. The final code is now.
/**
* Modify View custom field filters to use OR instead of AND
*/
function tssupp_filter_query_or($view_args, $view_settings, $view_id)
{
$view_ids = array( 199 ); // Edit. Array of View IDs to modify
if ( in_array($view_id, $view_ids) )
{
if ( !empty($_GET['wpv_view_count']) )
{
$view_args['meta_query']['relation'] = 'OR';
}
}
return $view_args;
}
add_filter('wpv_filter_query', 'tssupp_filter_query_or', 101, 3);