Problem:
The issue here is that the user wanted to remove their child terms from their taxonomy frontend filters in views.
Solution:
The can be done by using the hook below.
add_filter( 'wpv_filter_taxonomy_frontend_search_available_terms', 'prefix_modify_list_of_terms', 10, 3 ); function prefix_modify_list_of_terms( $terms, $taxonomy, $view_id ) { $curated_terms = array(); if($view_id == 478 && $taxonomy =='category'){ foreach ( $terms as $term ) { if ( $term->parent == 0 ) { $curated_terms[] = $term; } } } return $curated_terms; }
In order to get this to work for you, you will need to change 478 to the ID of your view and 'category' to the slug of the taxonomy that you want to remove the child terms for.
Add the code to your Toolset custom codes in Toolset -> Settings -> Custom Code and ensure that you've activated it.
Relevant Documentation:
For more information on this hook you can take a look at the link below.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
This topic contains 2 replies, has 2 voices.
Last updated by 4 years, 1 month ago.
Assisted by: Shane.