2 loops, both sticky posts, no duplicate posts
-
I’ve been trying to work out how to do the following on my homepage:
I need 2 loops:
loop 1: shows the first sticky post
loop2: shows the next 2 sticky posts but does not show the post above.I’ve been hacking at some code but cna’t get the no duplicate part to work:
LOOP1
<?php $do_not_duplicate = array(); $my_query = new WP_Query(array('posts_per_page' => 1, 'post__in' => get_option( 'sticky_posts' ) ) ); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate[] = $post->ID; ?> do stuff <?php endwhile; ?> <?php wp_reset_query(); ?>
LOOP 2
<?php $my_query = new WP_Query(array('posts_per_page' => 2, 'post__not_in' => $do_not_duplicate, 'post__in' => get_option( 'sticky_posts' ) ) ); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate[] = $post->ID; ?> do stuff <?php endwhile; ?>
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘2 loops, both sticky posts, no duplicate posts’ is closed to new replies.