Problem:
The user would like to exclude the child terms, in a taxonomy filter and only display the parent ones. The user would like to do the above for a view and an archive template.
Solution:
For taxonomy filters in posts views, prefer to use the wpv_filter_taxonomy_frontend_search_get_terms_args hook. Use something like:
add_filter( 'wpv_filter_taxonomy_frontend_search_get_terms_args', 'prefix_modify_get_terms_args', 10, 3 ); function prefix_modify_get_terms_args( $args, $taxonomy, $view_id ) { if ( $view_id == 1223 && $taxonomy == "topic") { $args['parent'] = 0; } return $args; }
Whereas for taxonomy views, prefer the wpv_filter_taxonomy_query hook. Something like:
add_filter( 'wpv_filter_taxonomy_query', 'prefix_modify_taxonomy_view_args', 99, 3 ); function prefix_modify_taxonomy_view_args( $tax_args, $view_settings, $view_id ) { if ( $view_id == 1201 ) { $tax_args['parent'] == 0; } return $tax_args }
Relevant Documentation:
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 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | - | - | 9:00 – 13:00 |
14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - | - | 14:00 – 18:00 |
Supporter timezone: Africa/Casablanca (GMT+01:00)
This topic contains 5 replies, has 2 voices.
Last updated by 3 years, 11 months ago.
Assisted by: Jamal.