Guest User

Untitled

a guest
Mar 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. <?php
  2.  
  3. // The Query
  4. $query1 = new WP_Query( $args );
  5.  
  6. if ( $query1->have_posts() ) {
  7. // The Loop
  8. while ( $query1->have_posts() ) {
  9. $query1->the_post();
  10. echo '<li>' . get_the_title() . '</li>';
  11. }
  12.  
  13. /* Restore original Post Data
  14. * NB: Because we are using new WP_Query we aren't stomping on the
  15. * original $wp_query and it does not need to be reset with
  16. * wp_reset_query(). We just need to set the post data back up with
  17. * wp_reset_postdata().
  18. */
  19. wp_reset_postdata();
  20. }
  21.  
  22. /* The 2nd Query (without global var) */
  23. $query2 = new WP_Query( $args2 );
  24.  
  25. if ( $query2->have_posts() ) {
  26. // The 2nd Loop
  27. while ( $query2->have_posts() ) {
  28. $query2->the_post();
  29. echo '<li>' . get_the_title( $query2->post->ID ) . '</li>';
  30. }
  31.  
  32. // Restore original Post Data
  33. wp_reset_postdata();
  34. }
  35.  
  36. ?>
Add Comment
Please, Sign In to add comment