My WP database has hundreds of categories. Most of the posts belong to 4 categories. For historical reasons, posts can also belong to other categories. For search filter, I only want to show these 4 categories as multi-checkboxes.
I don't see an obvious option for that. Can someone point me to the right direction?
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
Toolset views/blocks offers the filter that can help you to control what terms you want to display with your taxonomy filter.
You can add the following code to "Custom Code" section offered by Toolset or to your theme's functions.php file;
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/
For example:
add_filter( 'wpv_filter_taxonomy_frontend_search_get_terms_args', 'func_include_exclude_tags', 10, 3 );
function func_include_exclude_tags( $args, $tax, $view_id ){
if ( $view_id == 99999 && $tax == 'taxonomy-slug' ){
$args['include'] = array( 1, 2, 3,4 ); // Edit array of term IDs you want to allow of your 4 terms
}
return $args;
}
Where:
- Replace 99999 with your original view ID
- Replace 'taxonomy-slug' with your original taxonomy slug
More info:
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_taxonomy_frontend_search_get_terms_args