Created
February 7, 2014 14:17
-
-
Save DWboutin/8863377 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 ); | |
?> |
guys, How to display the data ? like title, custom post, etc ?
I try, $query->title(); is not working ...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for your snippets. The 11th line of code is very important!!!!