Two loops and excluding one post
-
So I have showcase kind of thing at the top of my homepage in which I put the most recent post that has the category “Featured Post.”
To get the post into the “showcase” div, I used a wp_query:
<div id="showcase"> <?php $featuredpost = new WP_Query('cat=16&posts_per_page=1'); ?> <?php while($featuredpost->have_posts()) : $featuredpost->the_post(); ?> <div id="featured" <?php post_class(); ?>> //LOOP STUFF SNIPPED OUT FOR BREVITY </div><!-- #featured --> <?php endwhile; ?> </div><!-- #showcase -->
Underneath the showcase comes the regular content section — via the regular Loop. But I want to exclude the $featuredpost from that loop so that the showcase post is not duplicated in the regular blog listing.
Was playing with this:
<?php query_posts(array('post__not_in' => $featuredpost)); ?>
just above the main loop. But that gave me no posts at all from the main loop. I can’t find any documentation on post__not_in in the codex.
Can anybody help me with this?
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Two loops and excluding one post’ is closed to new replies.