[wp-trac] [WordPress Trac] #28012: orderby post__in interferes with menu_order

WordPress Trac noreply at wordpress.org
Tue Apr 21 20:51:20 UTC 2015


#28012: orderby post__in interferes with menu_order
------------------------------------------+-------------------------
 Reporter:  Matthias82                    |       Owner:
     Type:  defect (bug)                  |      Status:  closed
 Priority:  normal                        |   Milestone:
Component:  Query                         |     Version:  3.9
 Severity:  normal                        |  Resolution:  worksforme
 Keywords:  needs-patch needs-unit-tests  |     Focuses:
------------------------------------------+-------------------------

Comment (by McGuive7):

 Hmmm, scratch that. I'm having the same issue. Here's my query:


 {{{
 $query_args = array(
         'posts_per_page'      => count( $post_in_array ),
         'post_type'           => 'campaign-spotlight',
         'order_by'            => 'post__in',
         'order'               => 'ASC',
         'post__in'            => $post_in_array,
         'ignore_sticky_posts' => true,
 );


 // Run query
 $the_query = new WP_Query( $query_args );
 }}}

 And here's what the SQL command ends up looking like:

 {{{
 SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  WHERE 1=1  AND
 wp_posts.ID IN (1973,1979,1976) AND wp_posts.post_type = 'campaign-
 spotlight' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status =
 'private')  ORDER BY wp_posts.post_date ASC LIMIT 0, 3
 }}}

 No idea why it's still ordering by post date. Any help?


 Replying to [comment:6 McGuive7]:
 > I'm experiencing the same issue, however in my case I believe it's
 coming from a page/post ordering plugin that overrides the query order_by
 parameter. Might this be the case for any of y'all?

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


More information about the wp-trac mailing list