i have list of post id's loop posts for, have tried using wp_query post__in, not keep order id's listed in inside $sorted array.
what simplest way of looping array of id's posts, overriding natural post order order $sorted array listed?
$args = array ( 'post__in' => $sorted, // array of id's want in order 'posts_per_page' => -1, // shows in array 'ignore_sticky_posts' => 1 // stickys dont affect order ); $query = new wp_query( $args ); // loop if ( $query->have_posts() ) { echo '<ul>'; while ( $query->have_posts() ) { $query->the_post(); echo '<li>n' . get_the_title() . ' - '. get_the_id () .'</li>'; } echo '</ul>'; } else { _e( 'sorry, no posts matched criteria.' ); } wp_reset_postdata();
you can use 'orderby' => 'post__in'
<?php $postsargs = array( "post_type" => "post", "orderby" => "post__in", "order" => "asc", "posts_per_page" => "-1", "post__in" => array(1,8,6) ); $posts = new wp_query($postsargs); ?>