Title: Multiple Loop Floop
Last modified: August 18, 2016

---

# Multiple Loop Floop

 *  [Leovenous](https://wordpress.org/support/users/leovenous/)
 * (@leovenous)
 * [19 years ago](https://wordpress.org/support/topic/multiple-loop-floop/)
 * I’ve been digging through the documentation for days and I guess I’m just not
   getting it. I have a page from a template I made that calls a category-specific
   loop, then later calls a page-specific loop, but in the latter it inserts the
   post from the former.
 * [http://www.globalencounter.net/registration](http://www.globalencounter.net/registration)
 * The first loop calls a category and uses their titles for the listbox. Then the
   page loop calls that page “registration” or “page_id=7” for my fake sidebar. 
   The post in there now is the content of one of the category posts. Here is my
   code for the first loop:
 *     ```
       <?php query_posts('category_name=upcoming-trips'); ?>
       <? while (have_posts()) : the_post(); ?>
       <option value="<?php the_title(); ?>"><?php the_title(); ?></option>
       <?php endwhile; ?>
       ```
   
 * And here is the second query… its not a loop cause a page has only one theoretical“
   post”, right?
 *     ```
       <?php query_posts( 'page_id=7' ); ?>
       <div class="post" id="post-<?php the_ID(); ?>">
       <div class="entry">
       <?php the_content(); ?>
       </div>
       </div>
       ```
   
 * I assume there is something stuck in a global that is not being replaced by the
   second query, but how to get out of this one I can’t figure out.

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

 *  Thread Starter [Leovenous](https://wordpress.org/support/users/leovenous/)
 * (@leovenous)
 * [19 years ago](https://wordpress.org/support/topic/multiple-loop-floop/#post-578922)
 * I’m still trying to work through this. Kind of in the read-documentation-for-
   the-tenth-time-and-blindly-experiment mode.
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [19 years ago](https://wordpress.org/support/topic/multiple-loop-floop/#post-578946)
 * Might try `<?php rewind_posts(); ?>` before that 2nd query.
 * Resources:
    [The Loop](http://codex.wordpress.org/The_Loop) [The Loop in Action](http://codex.wordpress.org/The_Loop_in_Action)
 *  Thread Starter [Leovenous](https://wordpress.org/support/users/leovenous/)
 * (@leovenous)
 * [19 years ago](https://wordpress.org/support/topic/multiple-loop-floop/#post-578991)
 * Ummm, thanks but, yeah that’s what I’ve been reading and reading (I have a loose
   grasp on PHP).
 * What gets me is; it is normal for me to run 2.. 3.. 4 loops on a page, and they
   don’t interfere with each other. But something about trying to call the Page 
   data, either by `have_post` or by `query_posts('page_id [or page]')` doesn’t 
   sit right.
 * I may break down and put the page content in a post and call it in specifically.
   Arg…
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [19 years ago](https://wordpress.org/support/topic/multiple-loop-floop/#post-578992)
 * > _And here is the second query… its not a loop cause a page has only one theoretical“
   > post”, right?_
 * Wrong. **A Loop must be a loop**. And yes, even Pages need Loops to display their
   content. Why? Because Pages are nothing more than special forms of Posts. A Page
   is a Post with a flag on it that says “page”.
 * So, try this instead:
 *     ```
       <?php query_posts( 'page_id=7' ); ?>
       <?php while (have_posts()) : the_post(); ?>
       <div class="post" id="post-<?php the_ID(); ?>">
       <div class="entry">
       <?php the_content(); ?>
       </div>
       </div>
       <?php endwhile; ?>
       ```
   
 * Now, while I say that, I’m also lying. 🙂 You don’t really have to have it in
   an actual Loop. What’s doing the work you’re actually wondering about here is
   the call to `the_post()`.
 * However, it’s a lot simpler if you just make Loops as actual loops. Don’t try
   weird variations. That way lies madness.
 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [19 years ago](https://wordpress.org/support/topic/multiple-loop-floop/#post-578993)
 * Since I am not a coder, for me the easiest way to include the content of a Page/
   post in a template is to use this plugin:
    [http://guff.szub.net/2005/01/27/get-a-post/](http://guff.szub.net/2005/01/27/get-a-post/)
 *  Thread Starter [Leovenous](https://wordpress.org/support/users/leovenous/)
 * (@leovenous)
 * [19 years ago](https://wordpress.org/support/topic/multiple-loop-floop/#post-578994)
 * Wow. Did you know you are very right sometimes Mosh? I had wondered about the_post
   but wasn’t able to gain enough understanding on it to see the light.
 * Okay, well after a few days of banging my head its nice to be moving forward 
   again. Thanks!

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

The topic ‘Multiple Loop Floop’ is closed to new replies.

## Tags

 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [multiple](https://wordpress.org/support/topic-tag/multiple/)
 * [page](https://wordpress.org/support/topic-tag/page/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [query](https://wordpress.org/support/topic-tag/query/)

 * 6 replies
 * 4 participants
 * Last reply from: [Leovenous](https://wordpress.org/support/users/leovenous/)
 * Last activity: [19 years ago](https://wordpress.org/support/topic/multiple-loop-floop/#post-578994)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
