Created
August 16, 2016 06:34
-
-
Save mzo84/7bce0b484005b59af1c34b0aea2ba745 to your computer and use it in GitHub Desktop.
Using WP_Query to create and customize multiple loops.
This file contains 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 // Loop 1 | |
$ rst_query = new WP_Query('cat=-1'); // exclude category | |
while($ rst_query->have_posts()) : $ rst_query->the_post(); | |
... | |
endwhile; | |
wp_reset_postdata(); // reset the query | |
// Loop 2 | |
$second_query = new WP_Query('cat=-2'); // exclude category | |
while($second_query->have_posts()) : $second_query->the_post(); | |
... | |
endwhile; | |
wp_reset_postdata(); // reset the query | |
// Loop 3 | |
$third_query = new WP_Query('cat=-3'); // exclude category | |
while($third_query->have_posts()) : $third_query->the_post(); | |
... | |
endwhile; | |
wp_reset_postdata(); // reset the query | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment