#39354 closed defect (bug) (fixed)
Unable to filter term query args using `pre_get_terms` action
Reported by: | jfarthing84 | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | 4.8 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | Taxonomy | Keywords: | has-patch |
Focuses: | Cc: |
Description
Thus making the action practically useless. But fear not, there is a simple remedy. In fact, the same remedy is used in WP_Query::get_posts
! Use a reference within WP_Term_Query::get_terms
to access the query vars locally:
$args = &$this->query_vars;
Attachments (1)
Change History (7)
#2
@
8 years ago
- Component changed from General to Taxonomy
- Milestone changed from Awaiting Review to 4.8
- Owner set to boonebgorges
- Status changed from new to reviewing
#5
@
8 years ago
A note, changeset 39625 breaks code which works in 4.7 and earlier:
$taxonomies = get_taxonomies(); $args = array( 'orderby' => 'count', 'order' => 'DESC' ); $terms = wp_get_object_terms( get_the_ID(), $taxonomies, $args );
It may be that this code is faulty and deserves to break (properly using get_object_taxonomies()
works), but I thought I would mention it, in case I'm not the only one affected.
Note: See
TracTickets for help on using
tickets.
Good call. Thanks for the patch, @jfarthing84.