[wp-trac] [WordPress Trac] #31045: Ordering a Query Using Multiple Meta Keys

WordPress Trac noreply at wordpress.org
Sun Feb 1 14:57:06 UTC 2015

#31045: Ordering a Query Using Multiple Meta Keys
 Reporter:  Funkatronic      |       Owner:  boonebgorges
     Type:  feature request  |      Status:  reopened
 Priority:  normal           |   Milestone:  4.2
Component:  Query            |     Version:  trunk
 Severity:  normal           |  Resolution:
 Keywords:  needs-patch      |     Focuses:

Comment (by boonebgorges):

 Just to bring the discussion from Slack back here to the ticket: I think
 Funkatronic's suggestion of using array indexes as orderby aliases is the
 most elegant solution to the problem. The main reason why I shied away
 from it when he suggested it in an earlier patch is because it doesn't
 seem WordPressy. I can't think of any other API where devs can pass
 arbitrary array indexes and have them interpreted in a meaningful way. The
 other consideration was that we do (or at least at one time we did) at
 times refer to the 0th item in `meta_query`, a reference that would break
 if we allowed associative keys. We can fix our own references, but it's
 possible that some plugins are doing the same thing, which introduces the
 possibility of breakage (however remote that may be).

 All of this being said, I'd be glad to go with the suggestion, as I think
 it's the most natural solution. So let's do it. We'll need a patch that
 updates the parsing logic, the unit tests, and the inline docs. We'll also
 need to make sure that we're not referencing the 0th member of the meta
 query anywhere - we should be using `reset()`.

Ticket URL: <https://core.trac.wordpress.org/ticket/31045#comment:26>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list