[wp-trac] [WordPress Trac] #37151: WP_Term_Query not honoring orderby meta_value_num
WordPress Trac
noreply at wordpress.org
Wed Jun 22 15:21:01 UTC 2016
#37151: WP_Term_Query not honoring orderby meta_value_num
-----------------------------+-----------------------------
Reporter: littler.chicken | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: trunk
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
I think this is related to ticket #35381, the introduction of the
WP_Term_Query class. I have a situation where I've created a taxonomy and
pre-populated it with about 60 terms. The order is not alphabetical or
anything, but should be consistent.
If I could be sure that no one would add new terms, I would order by ID
and leave it at that, but new terms might be added in certain cases, so
I've created a term metadata key and used a number for it to set the
order. I've put a filter on `get_terms_defaults` to set the orderby to use
the new term metadata.
In WP 4.5, this works--looks like 4.4 did not accept `meta_value` and
`meta_value_num` for `orderby` yet. However, in trunk, the
`meta_value_num` no longer works. As near as I can tell, the reason is
that
`$meta_clauses = $this->meta_query->get_clauses();`
(line 817 of `class-wp-term-query.php`) is returning an empty value, so
the `$orderby` parameter is returned as empty as well. I get completely
bogged down when I try to diagnose any further in the `WP_Meta_Query`
class, so I'm currently stumped. However, since it works in 4.5 and not in
4.6, I'm thinking it's a bug, so reporting it in the hopes that someone
else can help sort this.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37151>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list