-
-
Save yuriitaran/65d3043a201429661232a2d9ee04a8af to your computer and use it in GitHub Desktop.
Merge 2 WP_Query()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$query1 = new WP_Query($arg1); | |
$query2 = new WP_Query($arg2); | |
$query = new WP_Query(); | |
$query->posts = array_merge( $query1->posts, $query2->posts ); | |
// we also need to set post count correctly so as to enable the looping | |
$query->post_count = count( $query->posts ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment