Title: Two Loops integrated &#8211; issue
Last modified: August 19, 2016

---

# Two Loops integrated – issue

 *  Resolved [riccardo.malesani](https://wordpress.org/support/users/riccardomalesani/)
 * (@riccardomalesani)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/two-loops-integrated-issue-1/)
 * Hi, I want to expose an issue concerning the integration of two Loops.
    I have
   this slider (come from WP Coda Slider plugin), which calls pages:
 *     ```
       <?php query_posts('post_type=page&orderby=title&order=asc'); ?>
       <div class="scrollContainer">
       <?php while (have_posts()) : the_post(); ?>
       <div class="panel" id="<?php echo $post->post_name ; ?>">
       <?php the_content(); ?>
       </div>
       <?php endwhile;?>
       </div>
       ```
   
 * and it works great.
    In one page content, I run another php Loop to call the 
   posts list, like this:
 *     ```
       <?php query_posts ('post_type=post&order=desc'); ?>
       <?php while (have_posts()) : the_post(); ?>
       <li><a rel="group_news" href="<?php the_permalink() ; ?>"><?php the_title(); ?></a><?php echo '&nbsp;&nbsp;&nbsp;' ?><?php comments_number('No Comments','1 Comment','% Comments'); ?></li><?php endwhile;?>
       <?php wp_reset_query(); ?>
       ```
   
 * And the list is regularly called in that page, in that slider panel to be more
   precise.
 * Unfortunately, posts are also called in next panels of slider, as pages must 
   be, replacing them.
    In short: panel 1: page content (ok) panel 2: page content(
   ok) panel 3: page content – posts list of second loop (ok) panel 4: post content(
   wrong) panel 5: post content (wrong) …
 * in panel 4 and 5, I expect to have page 4 and 5 content, not the posts !
 * I can’t solve this
    thanks a lot

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

 *  [haxxxton](https://wordpress.org/support/users/haxxxton/)
 * (@haxxxton)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/two-loops-integrated-issue-1/#post-1970048)
 * if your slider is called before your page loop you might want your
 *     ```
       wp_reset_query();
       ```
   
 * after the Coda Slider endwhile; just to stop it from potentially interfering
 * also:
 * I had a similar thing happening to me the other day with the use of query_posts()
 * i changed to WP_query and it seemed to fix the issue.. have a look at the reference
 * [http://codex.wordpress.org/Function_Reference/WP_Query](http://codex.wordpress.org/Function_Reference/WP_Query)
 *  Thread Starter [riccardo.malesani](https://wordpress.org/support/users/riccardomalesani/)
 * (@riccardomalesani)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/two-loops-integrated-issue-1/#post-1970057)
 * Thanks, I’ll try with wp_reset_query or changing into WP_query, and i will let
   you know soon
 *  Thread Starter [riccardo.malesani](https://wordpress.org/support/users/riccardomalesani/)
 * (@riccardomalesani)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/two-loops-integrated-issue-1/#post-1970062)
 * Resetting query doesn’t fix. I try WP_query
 *  [haxxxton](https://wordpress.org/support/users/haxxxton/)
 * (@haxxxton)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/two-loops-integrated-issue-1/#post-1970065)
 * can you link me to the page this is happening on or are you using a local testing
   server?
 *  Thread Starter [riccardo.malesani](https://wordpress.org/support/users/riccardomalesani/)
 * (@riccardomalesani)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/two-loops-integrated-issue-1/#post-1970274)
 * Sorry for late, I’m using a local server but i’m going to publish it online soon.
 * Other says to reset query after slider, but issue remains.
    I forgot to specify
   that I’m using Exec PHP plugin in order to run the second loop into one page.
   I’m putting that php code directly into database page content.
 * I don’t think this could be the cause, second loop works but, as said, involves
   other slider pages, putting posts into them…
 *  Thread Starter [riccardo.malesani](https://wordpress.org/support/users/riccardomalesani/)
 * (@riccardomalesani)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/two-loops-integrated-issue-1/#post-1970293)
 * Finally I got it !
    I solved by moving the second loop from the page content 
   into a distinct slider panel.
 * Now the slider by the first loop calls pages and, separately, calls a single 
   special panel with the second posts loop.
 * I think this topic’s closed.
 * Thanks to haxxxton

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

The topic ‘Two Loops integrated – issue’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 2 participants
 * Last reply from: [riccardo.malesani](https://wordpress.org/support/users/riccardomalesani/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/two-loops-integrated-issue-1/#post-1970293)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
