[wp-trac] [WordPress Trac] #38034: post__in orderby not working when passed in an array to orderby

WordPress Trac noreply at wordpress.org
Wed Apr 19 10:59:56 UTC 2017


#38034: post__in orderby not working when passed in an array to orderby
--------------------------+-----------------------------
 Reporter:  kelvink       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  Query         |     Version:  4.6
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:
--------------------------+-----------------------------

Comment (by thefraj):

 Hi All,

 I came across this thread when I realised that the posts-in operator
 actually doesn't seem to work at all in the latest versions of Wordpress.

 Below is the sort of code I was using, it will not produce any results
 under any conditions that I can see (even if pages by this Id exist). I
 also tried casing using foreach ($posts as $p) : ... ... blah blah but
 have not been able to get any results back

 {{{#!php
 <?php

 $args = array(
 'post__in' => array(25199, 27, 1448, 6509)
 );
 $query = new WP_Query( $args );
 ?>
 <?php if ( $query->have_posts() ) : ?>
     <?php while ( $query->have_posts() ) : $query->the_post(); ?>
         <h2><?php the_title(); ?></h2>
         <?php echo the_content(); ?>

     <?php endwhile; ?>
 <?php endif; ?>
 <?php wp_reset_postdata(); ?>
 }}}

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


More information about the wp-trac mailing list