WordPress.org

Ready to get started?Download WordPress

Forums

Multiple loops messing up Next & Prev pages (3 posts)

  1. silencematters
    Member
    Posted 8 years ago #

    Hi there.
    here is a breakdown of what I am trying to do.

    On my index.php page, I am using a multiple loop to display the first post in full and the rest of the posts as excerpts.
    In all, I would like to display 3 posts on the index page, and use posts_nav_link() links to click to a next page, where I have the previous posts listed, showing only the Title & excerpts.
    The first Page looks fine. but when I click to the next page, I get the original First post, and then below that I get the 4th , 5th, 6th posts... is there a way to set this up so that the posts on the next pages are not affected by the forst loop on the index.php page?

    here is the code that is in my loops for index.php:

    <?php $my_query = new WP_Query('category_name=Uncategorized&showposts=1');
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID;?>

    <div class="blog_post">
    <?php require('post.php'); ?>
    <?php comments_template(); // Get wp-comments.php template ?>
    </div><!-- end post -->

    <?php endwhile; ?>

    <?php if (have_posts()) : while (have_posts()) : the_post();
    if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>

    <div class="blog_post">
    <?php include("post2.inc"); ?>
    <?php comments_template(); // Get wp-comments.php template ?>
    </div><!-- end post -->

    <?php endwhile; endif; ?>

    <p align="center"><?php posts_nav_link() ?>

    Thanks!
    -jeremy

  2. Samuel B
    moderator
    Posted 8 years ago #

  3. silencematters
    Member
    Posted 8 years ago #

    Thanks.. I will look through that and see if that solves things! Thanks for the help!

Topic Closed

This topic has been closed to new replies.

About this Topic