With your view:
- hidden link
I removed the existing query filter from "Query Filter" section that you added for "category" to filter with shortcode attribute "wpvcategory".
Within the "Search and Pagination" section I've added the following filter category filter:
<div class="form-group">
<label for="wpv-category">[wpml-string context="wpv-views"]Categories[/wpml-string]</label>
[wpv-control-post-taxonomy taxonomy="category" type="checkboxes" url_param="wpv-category"]
</div>
Now, To reduce the category terms to your desired terms:
=> Advisory & Consultancy, Data/Research, Resources/Tool
I've added the following filter hook to "Custom Code" section offered by Toolset with code snippet "toolset-custom-code":
=> hidden link
add_filter( 'wpv_filter_taxonomy_frontend_search_get_terms_args', 'func_modify_tax_terms_args_custom_search', 10, 3 );
function func_modify_tax_terms_args_custom_search( $args, $taxonomy, $view_id ) {
$target_views = array( 11727 ); // View with tax filter we wish to modify
if ( in_array( $view_id, $target_views ) ){
$term_slugs = array('advisory-consultancy','data-research', 'resources-tools');
$args['slug'] = $term_slugs;
}
return $args;
}
To hook in the shortcode argument value that holds the category "organization" I've added the following filter hook to "Custom Code" section offered by Toolset with code snippet "toolset-custom-code"
add_filter('wpv_filter_query', 'func_hookin_shortcode_attribute_value', 99, 3);
function func_hookin_shortcode_attribute_value ( $query_args, $view_settings, $view_id ) {
global $WP_Views;
if( $view_id == 11727) {
$shortcode_attr_value = $WP_Views->view_shortcode_attributes[0]['wpvcategory'];
$query_args['tax_query'][] =array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => $shortcode_attr_value
);
}
return $query_args;
}
Can you please confirm it works as expected now:
Frontend: hidden link
More info:
- https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_taxonomy_frontend_search_get_terms_args
- https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
- https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/#adding-custom-php-code-using-toolset