[wp-trac] [WordPress Trac] #9979: WP_Query orderby and order options not used as expected

WordPress Trac wp-trac at lists.automattic.com
Wed Jun 8 12:05:16 UTC 2011


#9979: WP_Query orderby and order options not used as expected
-------------------------------------+-----------------------------
 Reporter:  beaulebens               |       Owner:  ryan
     Type:  enhancement              |      Status:  new
 Priority:  low                      |   Milestone:  Future Release
Component:  Query                    |     Version:  2.8
 Severity:  minor                    |  Resolution:
 Keywords:  has-patch needs-testing  |
-------------------------------------+-----------------------------
Changes (by interconnectit):

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


Comment:

 The diff I've just added lets you add more than one 'order', space
 separated, to queries that have more than one 'orderby'. If you add three
 'orderby' statements and 2 'order' then the 3rd 'orderby' will have the
 first 'order'. If you were to add a fourth 'orderby' and leave the 'order'
 at 2 then the 4th 'orderby' would have the 2nd 'order'.

 eg.

 get_posts( array( 'orderby' => 'menu_order title', 'order' => 'DESC ASC'
 );
 Would sort by descending menu_order and ascending alphabetic title order.

 get_posts( array( 'orderby' => 'menu_order title date', 'order' => 'DESC
 ASC' );
 Would sort by descending menu_order and ascending alphabetic title order
 and descending date. Same as adding 'order' => 'DESC ASC DESC'

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9979#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list