Combining queries with different arguments per post type

One way is to customize the SQL query executed using posts_clauses or other such filters. To find them search for posts_clauses in “wp-includes/query.php” & see the series of filters just before this line. These together are capable of customizing any part of the query

Another thing you can do is manually merge the queried posts in the objects

$photos_query = new WP_Query( $photos );
$quotes_query = new WP_Query( $quotes );
$result = new WP_Query();

// start putting the contents in the new object
$result->posts = array_merge( $photos_query->posts, $quotes_query->posts );

// here you might wanna apply some sort of sorting on $result->posts

// we also need to set post count correctly so as to enable the looping
$result->post_count = count( $result->posts );

Leave a Comment