Last active
March 24, 2022 02:16
-
-
Save carlaizumibamford/71df42552fde3a82178089d976aa8733 to your computer and use it in GitHub Desktop.
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 | |
// The Query | |
$query1 = new WPQuery( $args ); | |
// The Loop | |
while ( $query1->have_posts() ) { | |
$query1->the_post(); | |
echo '<li>' . get_the_title() . '</li>'; | |
} | |
/* Restore original Post Data | |
* NB: Because we are using new WP_Query we aren't stomping on the | |
* original $wp_query and it does not need to be reset with | |
* wp_reset_query(). We just need to set the post data back up with | |
* wp_reset_postdata(). | |
*/ | |
wp_reset_postdata(); | |
/* The 2nd Query (without global var) */ | |
$query2 = new WP_Query( $args2 ); | |
// The 2nd Loop | |
while ( $query2->have_posts() ) { | |
$query2->the_post(); | |
echo '<li>' . get_the_title( $query2->post->ID ) . '</li>'; | |
} | |
// Restore original Post Data | |
wp_reset_postdata(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment