Title: Multiple loops
Last modified: August 19, 2016

---

# Multiple loops

 *  [richarduk](https://wordpress.org/support/users/richarduk/)
 * (@richarduk)
 * [18 years ago](https://wordpress.org/support/topic/multiple-loops-4/)
 * Hi, I’ve read the codex information about multiple loops and rewind and stuff
   like that.
 * I just want to make sure I’ve understood this correctly: if I want to use multiple
   loops then simply sticking (say) three ordinary loops on the page won’t work –
   ever? I’ve tried one loop for posts, and another loop for excerpts lower down
   the page, and that seemed to work fine.

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [ivovic](https://wordpress.org/support/users/ivovic/)
 * (@ivovic)
 * [18 years ago](https://wordpress.org/support/topic/multiple-loops-4/#post-766900)
 * no, using ordinary loops will work, but each one will clobber the previous, so
   if you’re done with them all by the time they are output, then you don’t really
   have a problem.
 * unfortunately things like pagination suffer, because often you want to use the
   paging information generated by the first loop, after you’ve done the others (‘
   cos the page links are at the bottom, under all the other loops which have clobbered
   the first one).
 * That’s the most common reason for needing to preserve the first… but not the 
   only one.
 *  Thread Starter [richarduk](https://wordpress.org/support/users/richarduk/)
 * (@richarduk)
 * [18 years ago](https://wordpress.org/support/topic/multiple-loops-4/#post-767034)
 * That’s a neat answer. Thanks.
 * Generally speaking it should be relatively easy to keep all the output from one
   loop separate from the output of other loops (you mentioned pagination as an 
   example where this might not happen). Provided I can do that, what are the other
   reasons?
 * Incidentally, from the Codex I can’t see what the point of rewind_posts is on
   its own UNLESS I use their method of changing around query_posts e.g. `<?php 
   $my_query = new WP_Query('category_name=special_cat&showposts=10'); ?>`
 * Still, rewind_posts looks like the best way to go provided I change around query_posts
   as it seems to be the simplest method.
 *  [ivovic](https://wordpress.org/support/users/ivovic/)
 * (@ivovic)
 * [18 years ago](https://wordpress.org/support/topic/multiple-loops-4/#post-767140)
 * your question about other reasons, and the purpose of rewind_posts are inextricably
   linked.
 * the_post advances the post counter so that once a post has been output, it isn’t
   stepped through again. Rewind_posts takes that counter and resets it.
 * This is useful if you want to reuse the query you just performed, for whatever
   reason. Instead of doing it again, rewind_posts will just allow you to step through
   it as though you’ve never outputted it before.
 * This is particularly useful for ‘contents’ style links like I have at the top
   of my sidebar on the main page — as it saves you doing the query again.
 * regardless of whether you change the query or not, rewind_posts just lets you
   use it as many times as you like.
 *  Thread Starter [richarduk](https://wordpress.org/support/users/richarduk/)
 * (@richarduk)
 * [18 years ago](https://wordpress.org/support/topic/multiple-loops-4/#post-767167)
 * ta!
 *  [bradstinyworld](https://wordpress.org/support/users/bradstinyworld/)
 * (@bradstinyworld)
 * [18 years ago](https://wordpress.org/support/topic/multiple-loops-4/#post-767172)
 * if you want to see the results of multiple loops I have three on this page [http://www.bradstinyworld.com](http://www.bradstinyworld.com)
   The first loop calls the latest post, the second one calls the second post, and
   the third loop calls the following 5 but only in excerpt.
 *  Thread Starter [richarduk](https://wordpress.org/support/users/richarduk/)
 * (@richarduk)
 * [18 years ago](https://wordpress.org/support/topic/multiple-loops-4/#post-767223)
 * BradsTinyWorld – you might be able to reduce the number of loops by reading this,
   which basically says if this is the first post post it in full, otherwise post
   excerpts
 * [http://perishablepress.com/press/2007/11/14/easily-adaptable-wordpress-loop-templates/](http://perishablepress.com/press/2007/11/14/easily-adaptable-wordpress-loop-templates/)
 * Similar to this
 * [http://www.cameraontheroad.com/?p=732](http://www.cameraontheroad.com/?p=732)
 * What I need to do is display three posts across the top of the page, magazine
   style. That’s one loop.
 * Underneath it I want four posts from one category; then another four from another
   category; then another four from another category. And then a different section
   below that. The layout I can work my way round; the categories I’m not sure about.
   I don’t really want to have 6 or seven loops.
 * Apart from comments, pings and date, are there any conditional tags that can 
   be used within The Loop?
 * [http://codex.wordpress.org/Conditional_Tags](http://codex.wordpress.org/Conditional_Tags)
 * Or is there any other way of saying, if in category 3, display latest 3 posts;
   if in category 4, display latest 3 posts etc? A counter would get me to 3 posts,
   six posts, but is it possible to select categories?
 *  Thread Starter [richarduk](https://wordpress.org/support/users/richarduk/)
 * (@richarduk)
 * [18 years ago](https://wordpress.org/support/topic/multiple-loops-4/#post-767228)
 * [http://www.headsetoptions.org/2008/01/11/anatomy-of-a-magazine-style-premium-wordpress-theme-part-1-the-loop/](http://www.headsetoptions.org/2008/01/11/anatomy-of-a-magazine-style-premium-wordpress-theme-part-1-the-loop/)
 * Looks like I can use `<?php if (in_category(#2)) : ?>` within the loop. Handy
   🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Multiple loops’ is closed to new replies.

## Tags

 * [multiple loops](https://wordpress.org/support/topic-tag/multiple-loops/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 3 participants
 * Last reply from: [richarduk](https://wordpress.org/support/users/richarduk/)
 * Last activity: [18 years ago](https://wordpress.org/support/topic/multiple-loops-4/#post-767228)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
