Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php get_header(); ?>
- <h1>Loop 1</h1>
- <?php $do_not_duplicate = array();
- $my_query = new WP_Query(array('posts_per_page' => 1, 'post__not_in' => get_option( 'sticky_posts' ) ) );
- while ($my_query->have_posts()) : $my_query->the_post();
- $do_not_duplicate[] = $post->ID; ?>
- <h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
- <?php endwhile; ?>
- <?php wp_reset_query(); ?>
- <h1>Loop 2</h1>
- <?php
- $args=array(
- 'posts_per_page' => 1,
- 'post__not_in' => $do_not_duplicate,
- 'category__in' => array($category->term_id)
- );
- $my_query = new WP_Query( $args );
- while ($my_query->have_posts()) : $my_query->the_post();
- $do_not_duplicate[] = $post->ID; ?>
- <h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
- <?php endwhile; ?>
- <?php wp_reset_query(); ?>
- <h1>Loop 3</h1>
- <?php $args=array(
- 'posts_per_page' => 1,
- 'post__not_in' => array_merge($do_not_duplicate, get_option( 'sticky_posts' )),
- 'category__in' => array($category->term_id)
- );
- $my_query = new WP_Query( $args );
- while ($my_query->have_posts()) : $my_query->the_post();
- $do_not_duplicate[] = $post->ID; ?>
- <h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
- <?php endwhile; ?>
- <?php wp_reset_query(); ?>
- <h1>Loop 4 (leftovers)</h1>
- <?php if (have_posts()) : while (have_posts()) : the_post();
- if (in_array($post->ID, $do_not_duplicate)) continue;
- ?>
- <h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
- <?php endwhile; ?>
- <?php else: ?>
- <?php endif; ?>
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement