Title: Multiple Loops
Last modified: August 20, 2016

---

# Multiple Loops

 *  Resolved [Danny159](https://wordpress.org/support/users/danny159/)
 * (@danny159)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/multiple-loops-11/)
 * Hi,
 * I have the following code in a template file (page-home.php) and I want to include
   bits of different pages in this file:
 * I have the following code:
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   The maximum number of lines of code that you can post in these forums is **ten
   lines**. Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * However the second loop doesn’t work… the ID is correct it just doesnt show anything…
 * Can anyone please help and spot my problem!
 * Dan

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

 *  Thread Starter [Danny159](https://wordpress.org/support/users/danny159/)
 * (@danny159)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/multiple-loops-11/#post-2805141)
 * Please see the code here: [http://pastebin.com/W1MPqEa0](http://pastebin.com/W1MPqEa0)
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/multiple-loops-11/#post-2805166)
 * I can’t see anything wrong with these near identical two blocks of code –
 * apart form using `query_posts()` for secondary loops; better to use `WP_Query()`–
   [http://codex.wordpress.org/Function_Reference/query_posts#Caveats](http://codex.wordpress.org/Function_Reference/query_posts#Caveats)
 * have you checked the html output in the browser, to see if the second loop’s 
   output is possibly just hidden?
 * what happens if you swap the page IDs between the queries?
    does the page 70 
   have direct children?
 *  Thread Starter [Danny159](https://wordpress.org/support/users/danny159/)
 * (@danny159)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/multiple-loops-11/#post-2805177)
 * Hi Thanks for you reply…
 * I replaced some code and added:
 *     ```
       <?php
       	$the_query = new WP_Query(array('page_id' => "18", 'post_type' => 'page'));
       	while($the_query->have_posts()) : $the_query->the_post();
           ?>
       ```
   
 * I changed the id’s around and still nothing… actually nothing at all shows now
   except my recent posts….
 * Here is my full new code: [http://pastebin.com/07D6Zd9R](http://pastebin.com/07D6Zd9R)
 * Dan
 * Also no pages have children yet
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/multiple-loops-11/#post-2805179)
 * > Also no pages have children yet
 * you were running queries looking for children pages….
 * [http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters)
 * [edit]
    just saw the edited queries; if those pages exist, there should be some
   output.
 * do you get at least the two empty divs?
 *     ```
       <div class="column_small" style="width:290px;">
       </div>
       ```
   
 * where is that pastebin code inserted in which tempalte?
 *  Thread Starter [Danny159](https://wordpress.org/support/users/danny159/)
 * (@danny159)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/multiple-loops-11/#post-2805182)
 * Ahhh but even this doesnt work:
 * `<?php $the_query = new WP_Query('page_id=18'); ?>`
 * Sorry for been stupid!
 *  Thread Starter [Danny159](https://wordpress.org/support/users/danny159/)
 * (@danny159)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/multiple-loops-11/#post-2805183)
 * Yes I get that… 🙁 dont know why…
 * Dan
 *  Thread Starter [Danny159](https://wordpress.org/support/users/danny159/)
 * (@danny159)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/multiple-loops-11/#post-2805186)
 * My full template code: [http://pastebin.com/DTTnWNvU](http://pastebin.com/DTTnWNvU)
 *  Thread Starter [Danny159](https://wordpress.org/support/users/danny159/)
 * (@danny159)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/multiple-loops-11/#post-2805193)
 * I fix this problem… I changed $the_query to $front_query1 and $front_query2 and
   now it all works.
 * Thanks for your help!

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

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

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 8 replies
 * 2 participants
 * Last reply from: [Danny159](https://wordpress.org/support/users/danny159/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/multiple-loops-11/#post-2805193)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
