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

WordPress Trac wp-trac at lists.automattic.com
Fri May 29 23:29:52 GMT 2009


#9979: WP_Query orderby and order options not used as expected
--------------------------+-------------------------------------------------
 Reporter:  beaulebens    |       Owner:  ryan      
     Type:  defect (bug)  |      Status:  new       
 Priority:  normal        |   Milestone:  Unassigned
Component:  Query         |     Version:  2.8       
 Severity:  normal        |    Keywords:            
--------------------------+-------------------------------------------------
 In WP_Query, "orderby" allows you to specify multiple columns, separated
 by spaces, to order your results by.

 You can only specify a '''single''' "order" value (ASC or DESC).

 If you specify multiple values in "orderby", "order" is applied to the end
 of the list, or effectively to the '''last''' "orderby" column.

 e.g. If a custom query specifies:

 'orderby' => 'title date', 'order' => 'DESC'

 it probably meant ORDER BY post_title DESC, post_date DESC (or maybe ASC,
 it's ambiguous), but I'll actually get:

 ORDER BY post_title, post_date DESC

 With MySQL's implied ASC on ORDER BY statements, this is the opposite of
 what I really wanted.

 We should either drop support for multiple-column ordering, allow for a
 way to specify a sort order per orderby/column, or at the very least apply
 the "order" to the '''first''' column specified, which seems like it'd be
 more likely to be intended outcome.

 See Also: #9978 for a sticky post bug that will need to implement this
 ordering logic as well.

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


More information about the wp-trac mailing list