0
如何獲取實際的$ first_ids,然後顯示$ second_ids。有了這個代碼,它仍然命令它們。不知道他們訂購了什麼,我猜Wordpress defualt排序?按時間順序顯示合併的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
));
?>