Skip to main content
Updated due to original question update
Source Link

I generally merge their ID arrays and make a third query. To keep first set of queries cheap I only return their ID's using fields parameter like this:

//setup your queries with extra parameter fields => ids
$query1 = new WP_Query(array('fields' => 'ids','other_parameters' => 'etc'));
$query2 = new WP_Query(array('fields' => 'ids','other_parameters'=>'etc'));

//now you got post IDs in $query->posts
$allTheIDs = array_merge($query1->posts,$query2->posts);

//new query, using post__in parameter
$finalQuery = new WP_Query(array('post__in' => $allTheIDs));

Hope this helps

---EDIT---

After my answer original question is edited for multisite details. In case of multisite post merges this does not work.

I generally merge their ID arrays and make a third query. To keep first set of queries cheap I only return their ID's using fields parameter like this:

//setup your queries with extra parameter fields => ids
$query1 = new WP_Query(array('fields' => 'ids','other_parameters' => 'etc'));
$query2 = new WP_Query(array('fields' => 'ids','other_parameters'=>'etc'));

//now you got post IDs in $query->posts
$allTheIDs = array_merge($query1->posts,$query2->posts);

//new query, using post__in parameter
$finalQuery = new WP_Query(array('post__in' => $allTheIDs));

Hope this helps

I generally merge their ID arrays and make a third query. To keep first set of queries cheap I only return their ID's using fields parameter like this:

//setup your queries with extra parameter fields => ids
$query1 = new WP_Query(array('fields' => 'ids','other_parameters' => 'etc'));
$query2 = new WP_Query(array('fields' => 'ids','other_parameters'=>'etc'));

//now you got post IDs in $query->posts
$allTheIDs = array_merge($query1->posts,$query2->posts);

//new query, using post__in parameter
$finalQuery = new WP_Query(array('post__in' => $allTheIDs));

Hope this helps

---EDIT---

After my answer original question is edited for multisite details. In case of multisite post merges this does not work.

Source Link

I generally merge their ID arrays and make a third query. To keep first set of queries cheap I only return their ID's using fields parameter like this:

//setup your queries with extra parameter fields => ids
$query1 = new WP_Query(array('fields' => 'ids','other_parameters' => 'etc'));
$query2 = new WP_Query(array('fields' => 'ids','other_parameters'=>'etc'));

//now you got post IDs in $query->posts
$allTheIDs = array_merge($query1->posts,$query2->posts);

//new query, using post__in parameter
$finalQuery = new WP_Query(array('post__in' => $allTheIDs));

Hope this helps