按时间顺序显示合并的Wordpress查询


Display merged Wordpress queries in chronological order

如何先显示实际的$first_id,然后再显示$second_id。有了这个代码,它仍然会订购它们。不确定它们是按什么排序的,我猜是Wordpress取消替换排序?

我试图实现的是,我在自定义帖子类型"飞机加油"内的所有帖子中添加了"特色"标签,我想先显示所有"特色"帖子,然后显示其余帖子。

<?php
// first query
$first_ids = get_posts( array(
    'fields'         => 'ids',
    'posts_per_page' => '999',
    'post_status'    => 'publish',
    'post_type'      => array('aircraft-refueling'),
    'tag' => 'featured'
));
// second query
$second_ids = get_posts( array(
    'fields'         => 'ids',
    'posts_per_page' => '999',
    'post_status'    => 'publish',
    'post_type'      => array('aircraft-refueling'),
    'tag__not_in' => array('592')
));
// merging ids
$post_ids = array_merge( $first_ids, $second_ids);
// the main query
$query = new WP_Query(array(
    'post_type' => 'aircraft-refueling',
    'post__in'  => $post_ids, 
    'paged'     => $paged
));
?>

我想明白了。合并查询后,在第三个查询上必须添加

'orderby' => 'post__in', // Preserve post ID order given in the post__in array (available since Version 3.5).

并按照从合并后的帖子数组中检索到的顺序放置帖子。