Allow terms to match the order in the include parameter#67
Conversation
…dering - Fix post order being scrambled on MariaDB / MySQL 8 when menu_order is re-normalized after gaps appear: refresh() now re-numbers deterministically in PHP instead of via a MySQL user-variable (@row_number) ranking whose evaluation order is undefined on those databases. Props @alexgw and @sebastiencyr (#147, #119). - Honor `orderby=include` in get_terms() / wp_get_object_terms() instead of overriding it with the custom term order; the term filters now receive $args. Props @glebkema (#67, #66). - Apply custom term ordering when any queried taxonomy is sortable (not only the first) and keep the caller's orderby as a fallback tiebreaker. Props @goaround (#104). No asset or data-format changes; fully backward compatible with 2.7.0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Thank you @glebkema — this was a thorough, well-reasoned write-up, and you were spot on. 🙏
Fixed in 2.7.1 (just released). The term filters now receive You're credited in the changelog. Closing as resolved — much appreciated! |
Fix #66
To fix the problem it's necessary to change the behavior of the plugin in two aspects.
1) scporder_get_terms_orderby()
This method is used with the filter
get_terms_orderbyand changes the$orderbyont.term_order.To fix this, it's enough to add one more check:
2) scporder_get_object_terms()
This method is used with two filters
get_termsandwp_get_object_termsand sorts the found terms by theterm_order.This situation is more complicated. To check the
includeoption in an array of arguments, we need to pass the$argsparameter to the function.But this parameter is located at different positions in the mentioned hooks:
In this regard, I propose to add an auxiliary method. Its role is to invoke a neighboring method with another set of arguments:
And use a specific function for each hook: