Problem: I have a taxonomy View that responds to a URL parameter, and should filter only terms that begin with that letter. In the past, this View was working correctly but it has begun to show inaccurate results.
Solution: Replace your taxonomy query filter code with the updated version below.
add_filter( 'wpv_filter_taxonomy_query', 'prefix_modify_tax_query', 10, 3 ); function prefix_modify_tax_query( $tax_query_settings, $view_settings, $view_id ) { if($view_id != 62 && isset($_GET['wpvalphabet']) && $_GET['wpvalphabet'] != '' ) { $tax_query_settings['name__like'] = $_GET['wpvalphabet']; } return $tax_query_settings; } function old_style_name_like_wpse_123298($clauses) { remove_filter('term_clauses','old_style_name_like_wpse_123298'); $splits = explode('}', $clauses['where']); $joins = array(); if(sizeof($splits) == 1) { return $clauses; } foreach($splits as $split) { $joins[] = substr($split, 0, strpos($split, '{')); } $clauses['where'] = join($joins, '') . (sizeof($joins) > 1 ? "%'" : ''); return $clauses; } add_filter('terms_clauses','old_style_name_like_wpse_123298');
Relevant Documentation: https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_taxonomy_query
https://developer.wordpress.org/reference/hooks/terms_clauses/
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 |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 4 replies, has 2 voices.
Last updated by morktron 6 years, 1 month ago.
Assisted by: Christian Cox.