Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- First loop (I show the last 3 sticky posts)
- <?php $do_not_duplicate = array();
- $my_query = new WP_Query(array('posts_per_page' => 3, 'post__in' => get_option( 'sticky_posts' ), 'caller_get_posts' => 1 ) );
- while ($my_query->have_posts()) : $my_query->the_post();
- $do_not_duplicate[] = $post->ID; ?>
- HTML CODE HERE
- <?php endwhile;?>
- <?php wp_reset_query(); ?>
- Second loop (the 4 latest posts, excluding stickies)
- <?php ////$do_not_duplicate = array();////remove this; this line is only allowed once before the first loop
- $my_query = new WP_Query(array('posts_per_page' => 4, 'post__not_in' => array_merge($do_not_duplicate, get_option( 'sticky_posts' ) ) ) );
- while ($my_query->have_posts()) : $my_query->the_post();
- $do_not_duplicate[] = $post->ID; ?>
- HTML CODE HERE
- <?php endwhile;?>
- <?php wp_reset_query(); ?>
- Third loop (showing the latest post from each cateogry, excluding stickies)
- <?php
- $cat_args=array(
- 'orderby' => 'name',
- 'order' => 'ASC'
- );
- ////$do_not_duplicate = array();////remove this; this line is only allowed once before the first loop
- $categories=get_categories($cat_args);
- foreach($categories as $category) {
- $args=array(
- 'posts_per_page' => 1,
- 'post__not_in' => array_merge($do_not_duplicate,get_option( 'sticky_posts' )),
- 'category__in' => array($category->term_id),
- );
- $posts=get_posts($args);
- if ($posts) {
- $ncat = '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>';
- foreach($posts as $post) {
- setup_postdata($post);
- $do_not_duplicate[] = $post->ID; ?>
- HTML CODE HERE
- <?php
- }
- }
- }
- ?>
- <?php wp_reset_query(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement