So, it required some additional filters and efforts.
I've removed the taxonomy query filters from "Query Filter" section of the following view and added the AREA as dropdown select filter.
=> hidden link
I've added the following code to "Custom Code" section offered by Toolset with code snippet "toolset custom code":
=> hidden link
The following filter is used to filter the view's query on fly and filter the view results with passed shortcode arguments for wpvarea and wpvcollection.
add_filter( 'wpv_filter_query', 'func_filter_multiple_shortcode_attributes', 10, 3 );
function func_filter_multiple_shortcode_attributes( $query, $view_settings, $views_id ) {
if ( $views_id == 88377 ) {
global $WP_Views;
$area_terms = $WP_Views->view_shortcode_attributes[0]['wpvarea'];
$collection_terms = $WP_Views->view_shortcode_attributes[0]['wpvcollection'];
$area_terms = explode(',', $area_terms);
$collection_terms = explode(',', $collection_terms);
if(defined('DOING_AJAX') && DOING_AJAX){
$query['tax_query'][] = array(
'taxonomy' => 'collection',
'field' => 'slug',
'terms' => $collection_terms,
'operator' => 'IN',
);
$query['tax_query']['relation'] = 'AND';
}else{
$query['tax_query'][] = array(
'taxonomy' => 'area',
'field' => 'slug',
'terms' => $area_terms,
'operator' => 'IN',
);
$query['tax_query'][] = array(
'taxonomy' => 'collection',
'field' => 'slug',
'terms' => $collection_terms,
'operator' => 'IN',
);
$query['tax_query']['relation'] = 'AND';
}
}
return $query;
}
The following "wpv_filter_taxonomy_frontend_search_get_terms_args" filter is used to restrict the Area dropdown options to the terms you passed to shortcode attribute: wpvarea="norfolk,suffolk,devon,cornwall,south-coast,yorkshire,somerset,dorset".
It will display only options as filter option for terms: norfolk,suffolk,devon,cornwall,south-coast,yorkshire,somerset,dorset
add_filter( 'wpv_filter_taxonomy_frontend_search_get_terms_args', 'func_filter_tax_terms_dropdown', 10, 3 );
function func_filter_tax_terms_dropdown( $args, $tax, $view_id ){
global $WP_Views;
if ( $view_id == 88377 && $tax == 'area' ){
$area_terms = $WP_Views->view_shortcode_attributes[0]['wpvarea'];
$area_terms = explode(',', $area_terms);
$args['slug'] = $area_terms;
}
return $args;
}
Can you please confirm it works as expected: hidden link
I hope this will satisfies your requirements 🙂