[wp-trac] [WordPress Trac] #61859: meta_value_num order calse in WP_Term_Query cannot work as meta_query is evaluated after setting up the order
WordPress Trac
noreply at wordpress.org
Mon Aug 12 10:23:37 UTC 2024
#61859: meta_value_num order calse in WP_Term_Query cannot work as meta_query is
evaluated after setting up the order
--------------------------+-------------------------------
Reporter: gaelwanaka | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: 6.6.1
Severity: major | Keywords: reporter-feedback
Focuses: |
--------------------------+-------------------------------
Hello,
Wordpress : 6.6.1.
Plugins : none.
Theme : any
Gutenberg : irrevelant
As the title says, when setting up orderby clause in a WP_Term_Query to
"meta_num_value", the order always falls back on "name".
Thats cames from the "parse_orderby", that tries to evaluate if there is
any meta query clauses, to check if the meta_value_num should be effective
or not.
In the WP_Term_Query::get_terms; things are called in this order :
- checks the meta_order conditions
- check if there is some meta query clauses
- if not, fallback to order by title
- later on, parse the meta_query and initiate the clauses (on
WP_Term_Query::meta_query->parse_query_vars)
So, as the meta_query is parses after checking the orderby, than the
orderby is never setup to meta_value_num.
Thanks a lot,
Best regards
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61859>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list