[wp-trac] [WordPress Trac] #31045: Ordering a Query Using Multiple Meta Keys
WordPress Trac
noreply at wordpress.org
Mon Jan 19 15:51:21 UTC 2015
#31045: Ordering a Query Using Multiple Meta Keys
-----------------------------+-----------------------------
Reporter: Funkatronic | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Future Release
Component: Query | Version: trunk
Severity: normal | Resolution:
Keywords: needs-patch | Focuses:
-----------------------------+-----------------------------
Changes (by boonebgorges):
* keywords: => needs-patch
* milestone: Awaiting Review => Future Release
Comment:
A big +1. I've had the same idea in the past; see #29447 and point 4 in
https://core.trac.wordpress.org/ticket/25538#comment:26.
Adding an 'alias' argument to meta_query clauses seems like the most
consistent way forward. `WP_Query` already supports multiple ORDER BY
clauses (see https://make.wordpress.org/core/2014/08/29/a-more-powerful-
order-by-in-wordpress-4-0/ and #17065), so the 'orderby' syntax would have
to integrate with that. I would lean toward *not* using a `'meta-'` prefix
for aliases, since (a) the possibility of clashes is very slight, and (b)
developers have full control over 'alias' and so it's not unreasonable to
expect them to check for clashes themselves.
Ideally, these aliases would also be used in building the SQL itself,
which would make certain kinds of SQL filters easier to write. Aliases are
currently generated here
https://core.trac.wordpress.org/browser/tags/4.1/src/wp-
includes/meta.php#L1353, and this would need a bit of reworking to ensure
that ordering works properly with shared table aliases.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31045#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list