Multiple Loop Question
-
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. Thanks1st 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.