Title: Multiple Loops, Do Not Duplicate Issues
Last modified: August 19, 2016

---

# Multiple Loops, Do Not Duplicate Issues

 *  [astereo](https://wordpress.org/support/users/astereo/)
 * (@astereo)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/multiple-loops-do-not-duplicate-issues/)
 * Hey all. I’m having a bit of trouble getting my loops to work the right way…basically
   what I’m trying to do is have two loops – one that will show the x number of 
   recent posts as specified in the WP options panel, and another that will show
   the latest 15 posts from a specific category, in this case called products. I
   have followed the codex instructions and can’t seem to figure out what exactly
   is wrong and why the posts are still be duplicated. See my loop code below.
 *     ```
       <div class="news">
   
        <?php if (have_posts()) : while (have_posts()) : the_post();
         if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
   
       			<!-- Post Stuff -->
   
       <?php endwhile; endif; ?>
   
       		<div class="navigation">
       			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
       			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
       		</div>
   
           </div>
   
       <div class="products">
   
         <?php $i = 0; // Create a new (incrementing) var ?>
         <?php $my_query = new WP_Query('category_name=products&showposts=15');
   
         while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; // check for product large image
       $pli = get_post_meta($post->ID, 'pli', $single = true); // check for item price
       $price = get_post_meta($post->ID, 'price', $single = true); ?>
   
         <?php $i++; // Increase count ?>
   
       <!-- Post Stuff -->
   
         <?php if ($i % 3 == 0): // if the result of the incrementing var is equal to zero ?>
         <div class="spacer"></div>
       <?php endif; ?>
         <?php endwhile; ?>
       </div>
       ```
   
 * The incrementing var stuff is used to display posts the right way in a grid format.
   I removed additional display code from the above code sample.
 * Any help would be greatly appreciated!
    Thanks in advance!!

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

 *  Thread Starter [astereo](https://wordpress.org/support/users/astereo/)
 * (@astereo)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/multiple-loops-do-not-duplicate-issues/#post-762655)
 * Any ideas ?
 *  Thread Starter [astereo](https://wordpress.org/support/users/astereo/)
 * (@astereo)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/multiple-loops-do-not-duplicate-issues/#post-762782)
 * Still haven’t been able to figure this out :S
 *  Thread Starter [astereo](https://wordpress.org/support/users/astereo/)
 * (@astereo)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/multiple-loops-do-not-duplicate-issues/#post-762842)
 * bump
 *  Thread Starter [astereo](https://wordpress.org/support/users/astereo/)
 * (@astereo)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/multiple-loops-do-not-duplicate-issues/#post-762876)
 * I hate to keep bumping this, but I’m developing a theme and this is the only 
   thing that stands in the way of getting it completed.
 *  [jonimueller](https://wordpress.org/support/users/jonimueller/)
 * (@jonimueller)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/multiple-loops-do-not-duplicate-issues/#post-762877)
 * If you read the codex documentation you’ll find there’s a way to tell the WP 
   loop not to repeat the post twice.
 * Go here:
    [http://codex.wordpress.org/The_Loop](http://codex.wordpress.org/The_Loop)
 * And scroll down to Multiple Loops in Action. You’ll see YOUR EXACT SCENARIO laid
   out for you in plain English and it took me less than five seconds to find it.
   Sorry you had to keep bumping this post. You should have been looking in the 
   Codex instead of waiting for someone to hand you this information.
 * If you ask me, you’ve got a lot more standing in the way than just your inabilty
   to solve your theme issue.
 *  Thread Starter [astereo](https://wordpress.org/support/users/astereo/)
 * (@astereo)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/multiple-loops-do-not-duplicate-issues/#post-762894)
 * Maybe if you read my post you would see that I have looked in the codex. I have
   developed 7 WordPress themes in the past. My code is exactly how it should be
   as per the instructions in the codex and it is not working.
 *  Thread Starter [astereo](https://wordpress.org/support/users/astereo/)
 * (@astereo)
 * [18 years ago](https://wordpress.org/support/topic/multiple-loops-do-not-duplicate-issues/#post-762895)
 * And to further test if do not duplicate worked or not, I replaced the loop with
   the exact one from the WordPress codex and posts were **still being duplicated**.(
   WP 2.5)
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [18 years ago](https://wordpress.org/support/topic/multiple-loops-do-not-duplicate-issues/#post-762897)
 * > If you ask me, you’ve got a lot more standing in the way than just your inabilty
   > to solve your theme issue.
 * Could you mean his ego?
 * There are a few threads on this happening, if your code is the way it’s s’posed
   to be you might want to look through those threads.
 *  [Zambrano Sergio](https://wordpress.org/support/users/sergiozambrano/)
 * (@sergiozambrano)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/multiple-loops-do-not-duplicate-issues/#post-763059)
 * Make sure you are not duplicating your index.php (or single.php or any other)
   in your server to test them.
 * If you did, make sure you replace the pagename at the top of the code, or wp 
   will read the first file it finds matching that name. wp doesn’t use filenames
   to find s page’s tamplate but that internal code.
 * If that’s not the problem… I hope you fix it, since I’ve been helped with a script
   for a double loop which is doing the same to me (same content for both loops)
 * [http://wordpress.org/support/topic/251068?replies=3#post-1023595](http://wordpress.org/support/topic/251068?replies=3#post-1023595)

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

The topic ‘Multiple Loops, Do Not Duplicate Issues’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 9 replies
 * 4 participants
 * Last reply from: [Zambrano Sergio](https://wordpress.org/support/users/sergiozambrano/)
 * Last activity: [17 years, 2 months ago](https://wordpress.org/support/topic/multiple-loops-do-not-duplicate-issues/#post-763059)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
