Skip to content

Instantly share code, notes, and snippets.

@ramseyp
Created April 25, 2012 05:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramseyp/2486644 to your computer and use it in GitHub Desktop.
Save ramseyp/2486644 to your computer and use it in GitHub Desktop.
Merge two wp_queries using array_merge
<?php
/**
* Merging two queries
*
*/
$query1 = new WP_Query(array(
'post_type' => 'page',
'post_parent' => 341,
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
));
$query2 = new WP_Query(array(
'post_type' => 'page',
'post_parent' => 109,
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
));
$querysmash = array_merge($query1->posts, $query2->posts);
foreach ($bigm as $post) : setup_postdata($post);
// Do something
endforeach; wp_reset_postdata();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment