Multiple loops + get_posts : how to avoid duplication
$posts = get_posts('numberposts=10&offset=1'); foreach ($posts as $post): setup_postdata($post);
The code above resets the counter, and re-runs the loop. The offset can be set to whatever you want, the default is 0.
To avoid duplication, you need to test against the first post in the second loop :
while($top_query->have_posts()) : $top_query->the_post(); $first_post = $post->ID;Then the new second loop:
query_posts('showposts=6'); ?> <?php while(have_posts()) : the_post(); if(!($first_post == $post->ID)) :
~ template tags 'n stuff go here ~
endif; endwhile;
The solution also works if you want to get the posts displayed in columns. Use a query for each column and display the result in the appropriate div.




Leave a Reply