Multiple loops & featured posts
-
Hi, I am trying to display a “featured posts” part on my page while on the rest of the page to display the other posts, and no duplicated posts should show up. I used the same code as in the wordpress documentation “The Loop”:
<?php global $do_not_duplicate; $do_not_duplicate = array(); ?> <?php $my_query = new WP_Query('cat=95&showposts=10'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate[] = $post->ID; ?> <!-- do stuff --> <?php endwhile; ?> <?php if (have_posts()) : while (have_posts()) : the_post(); if (in_array($post->ID, $do_not_duplicate)) { continue; } update_post_caches($posts); ?> <!-- do stuff --> <?php endwhile; endif; ?>
It turned out only the first(latest) featured post was not duplicated, and the other featured posts all showed twice. I really cannot figure out what is wrong. Can someone help me out with this? Thanks!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Multiple loops & featured posts’ is closed to new replies.