WP_query ‘orderby=none’ Problem

You can order them manually after the query is complete:

$ids = array (60, 23, 78, 46, 105, 130)

$args = array (
    'posts_per_page' => -1,
    'post__in' => $ids,
    'orderby' => 'none'
);

$query = new WP_Query ( $args );

$ordered_posts = array();
foreach($ids as $rpid)
 foreach($query->posts as $index => $fpid)
   if($fpid->ID === $rpid) $ordered_posts[] = $query->posts[$index];

$query->posts = $ordered_posts;

while ($query->have_posts() ) : $query->the_post();
    echo '<li>';
    the_title();
    echo '</li>';
endwhile;

And like Mamaduka posted, if it’s a custom loop use the $query methods instead of the global functions…

Leave a Comment