查询完成后,您可以手动订购:
$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;
就像Mamaduka发布的一样,如果是自定义循环,请使用$查询方法而不是全局函数。。。