0
我已經創建了一個Wordpress查詢合併兩個現有的查詢,我將如何停止顯示第一個查詢已顯示的帖子的第二個查詢?從合併的Wordpress循環隱藏重複的帖子
$args_for_query1 = array(
'meta_key' => '_mcf_homeoperator',
'meta_value' => 'Yes',
'posts_per_page' => 14,
'cat' => 521,
'post__in' => get_field('srtby_homepage', 'option', false, false),
'orderby' => 'post__in'
);
$args_for_query2 = array(
'posts_per_page' => 20,
'cat' => 12,22411,
'post__in' => get_field('srtby_slotspage', 'option', false, false),
'orderby' => 'post__in',
);
$query1 = new WP_Query($args_for_query1);
$query2 = new WP_Query($args_for_query2);
// Main Loop
$args=array(
'paged' => $paged,
'showposts' => 20,
);
$wp_query = new WP_Query($args);
$wp_query->posts = array_merge($query1->posts, $query2->posts);
$wp_query->post_count = $query1->post_count + $query2->post_count;
if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post();
我需要第三查詢,以控制多少職位被輸出到頁面,設置分頁 – James
@詹姆斯我認爲這不太工作,你指望它。你用直接MySQL查詢而不是wp_query好嗎? –