Skip to content

Check all taxonomies if any of them should be sorted#104

Closed
goaround wants to merge 1 commit into
ColorlibHQ:masterfrom
goaround:patch-1
Closed

Check all taxonomies if any of them should be sorted#104
goaround wants to merge 1 commit into
ColorlibHQ:masterfrom
goaround:patch-1

Conversation

@goaround

Copy link
Copy Markdown

Applies the orderby t.term_order if any of the queried taxonomies should be orderby and adds the default orderby as a fallback

puikinsh added a commit that referenced this pull request Jun 2, 2026
…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>
@puikinsh

puikinsh commented Jun 2, 2026

Copy link
Copy Markdown
Member

Thank you @goaround! 🙏 The core idea here was a good catch: only the first taxonomy in a multi-taxonomy query was being considered, and the original orderby was discarded entirely.

Addressed in 2.7.1 (just released). scporder_get_terms_orderby() now applies our ordering when any queried taxonomy is sortable (via array_intersect) and prepends t.term_order while keeping the caller's orderby as a fallback tiebreaker — e.g. t.term_order, t.name. We also folded in the orderby=include handling from #67 so explicit ordering is respected.

One small note for posterity: the original diff referenced $taxonomy after the line that assigned it was removed, so it would have errored as-is — we reworked the change against the current 2.7.x codebase. You're credited in the changelog for the idea. Closing as resolved — thanks for the contribution!

@puikinsh puikinsh closed this Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants