我想将两个查询合并在一起并删除重复的查询。我让它单独工作。现在我把它一起工作了,但结果没有混合,重复项也没有删除。所以我得到了第一个查询结果,然后是第二个查询结果。。。
$fav_author_list = get_user_option( \'favorite-authors\', fav_authors_get_user_id() );
$fav_categorie_list = get_user_option( \'favorite-categories\', fav_categories_get_user_id() );
$rm_blog_args = array(
\'posts_per_page\' => -1,
\'author__in\'=> $fav_author_list,
\'post_type\' => \'post\'
);
$rm_blog = new WP_Query($rm_blog_args);
$fb_args = array(
\'posts_per_page\' => -1,
\'category__in\'=> $fav_categorie_list,
\'post_type\' => \'post\'
);
$fb = new WP_Query($fb_args);
// Final Query
$final_query = new WP_Query();
// Merging queries
$final_query->posts = array_merge( $rm_blog->posts, $fb->posts);
// Recount
echo $final_query->post_count = count( $final_query->posts );
// Remove duplicate post IDs
$post_ids = array();
foreach( $final_query->posts as $item ) {
$post_ids[] = $item->ID;
}
$unique_posts = array_unique($post_ids);
if($final_query->have_posts()) : while ( $final_query->have_posts() ) : $final_query->the_post();