[wp-trac] [WordPress Trac] #17065: Independent ASC/DESC in multiple ORDER BY statement.

WordPress Trac noreply at wordpress.org
Thu Jun 12 17:54:51 UTC 2014


#17065: Independent ASC/DESC in multiple ORDER BY statement.
-------------------------+-----------------------
 Reporter:  ericmann     |       Owner:  ericmann
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  4.0
Component:  Query        |     Version:  3.1
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:
-------------------------+-----------------------
Changes (by wonderboymusic):

 * keywords:  has-patch needs-testing needs-unit-tests => has-patch


Comment:

 In [attachment:17065.2.diff 17065.2.diff], use this syntax:

 {{{
 $q = new WP_Query( array(
         'orderby' => array(
                 'type' => 'DESC',
                 'name' => 'ASC'
         )
 ) );
 }}}

 Basically, if you pass an array, we know you are doing this. You must pass
 `field_alias => order`.  This is easy to understand and hard to screw up.
 `order`, in this case, is ignored if passed.

 Added unit tests. If you pass `orderby => array()`, there will be no
 `ORDER BY` clause created.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/17065#comment:60>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list