#44505 closed enhancement (duplicate)
term_order is an invalid orderby parameter in WP_Term_Query::get_terms()
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | |
Component: | Taxonomy | Keywords: | |
Focuses: | Cc: |
Description
This is a follow-up to #35381.
I'm wondering why term_order
is not allowed as the orderby
parameter in WP_Term_Query::get_terms()
for functions like get_terms()
. It is specifically invalidated on line 388. Granted, term_order isn't used for much in core right now, but the column is there, and one generally expects any column heading to be a valid orderby parameter. The workaround is to create custom meta for the terms and add a meta_query
. There are examples on StackExchange/Overflow of people looking for a remedy. In fact, there is an example of this on trac ticket:34996, where the example used for justifying the addition of meta_query only exists because term_order is a rejected orderby.
I'm marking this as an "enhancement" because the code does what is intended, but unless one delves into the source code, it feels like a bug.
Hi @swinggraphics - Thanks for your ticket, and welcome to WordPress Trac!
The
term_order
column is in thewp_term_relationships
table. As such, it's only possible to use that column for ordering when joining against therelationships
table, andWP_Term_Query
only does this whenobject_ids
are passed to the query. So the limitation you've cited inWP_Term_Query
is technical - it's not possible to remove it.The ability to specify term order would be an interesting feature, and has been proposed in a number of places. See #30244, #9547. These solutions would have to use something other than the
term_order
column inwp_term_relationships
, for backward compatibility and other reasons, but those tickets have some good discussion about what such a feature might look like.