I merged two WP_Queries with the code below, it has pagination setup as well as posts per page in the final combined object but those settings aren't working. My page shows 24 posts, where is it getting this number from and why isn't pagination working?
$args1 = array(
'post_type' => 'post',
'posts_per_page' => -1
);
$query1 = new WP_Query( $args1 );
$args2 = array(
'post_type' => 'product',
'product_tag' => 'home',
'posts_per_page' => -1
);
$query2 = new WP_Query( $args2 );
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$finalargs = array(
'paged' => $paged,
'posts_per_page' => 3
);
$wp_query = new WP_Query($finalargs);
$wp_query->posts = array_merge( $query1->posts, $query2->posts );
$wp_query->post_count = count( $wp_query->posts );
echo '<pre>';
//var_dump($wp_query); exit(0);
echo '</pre>';
The output of var_dump is below, so if my wp_query has posts per page and pagination setup why isn't it working?
object(WP_Query)#566 (47) {
["query"]=>
array(2) {
["paged"]=>
int(1)
["posts_per_page"]=>
int(3)
}
["query_vars"]=>
array(61) {
["paged"]=>
int(1)
["posts_per_page"]=>
int(3)
["error"]=>
string(0) ""
["m"]=>
string(0) ""
["p"]=>