Title: Multiple Loop Question
Last modified: August 19, 2016

---

# Multiple Loop Question

 *  [jitpal](https://wordpress.org/support/users/jitpal/)
 * (@jitpal)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/multiple-loop-question-2/)
 * Hi everyone, I can’t seem to figure this out. I’m sure I’m making some silly 
   mistake. Im trying to create a semi-static homepage with 3 loops. The top one
   for just sticky posts, the 2nd one for non-sticky posts with a specific tag and
   the 3rd one for new posts. Obviously avoiding duplicates in the process. The 
   sticky posts show up fine, no problems there. The problems being in the second
   loop, where the sticky posts would overflow in, that I solved with `caller_get_posts
   =1` So now the second loop only shows the newest posts, it is not filtering out
   the ones that don’t have that specific tag. Then the third loop doesn’t show 
   anything at all. Any help would be greatly appreciated. Thanks
 * 1st Loop:
 *     ```
       <?php $ids = array();
       	$sticky=get_option('sticky_posts');
       	rsort( $sticky );
       	$sticky = array_slice( $sticky, 0, 4 );
       	$saleArgs=array(
       	'caller_get_posts' => 1,
          	'showposts'=>4,
          	'post__in' => $sticky,
          );
       $mySalePosts = new WP_Query();
       $mySalePosts->query($saleArgs);
       while ($mySalePosts->have_posts()) : $mySalePosts->the_post(); ?>
       //Stuff
       <?php $ids[]= $post->ID; endwhile; wp_reset_query(); ?>
       ```
   
 * 2nd Loop:
 *     ```
       <?php
       $fastArgs=array(
       	'tag_slug__in' => '24hr',
       	'showposts' => 4,
       	'caller_get_posts' => 1,
       );
       $my24hrPosts = new WP_Query();
       $my24hrPosts->query($fastArgs);
       while ($my24hrPosts->have_posts()) : $my24hrPosts->the_post(); ?>
       	<?php if (!in_array($post->ID, $ids)) { ?>
       //Stuff
       <?php $ids[]= $post->ID; } endwhile; wp_reset_query(); ?>
       ```
   
 * 3rd Loop:
 *     ```
       <?php
       $newArgs=array(
       	'tag_slug__not_in' => '24hr',
       	'showposts' => 4,
       	'caller_get_posts' => 1,
       );
       $myNewPosts = new WP_Query();
       $myNewPosts->query($newArgs);
       while ($myNewPosts->have_posts()) : $myNewPosts->the_post(); ?>
       	<?php if (!in_array($post->ID, $ids)) { ?>
       //Stuff
        <?php $ids[]= $post->ID; } endwhile; wp_reset_query(); ?>
       ```
   

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

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [jitpal](https://wordpress.org/support/users/jitpal/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/multiple-loop-question-2/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
