• Resolved vossavant

    (@vossavant)


    Please answer my prayers WordPress gurus…

    I’m trying to display posts from two categories using the query_posts function. I have two test posts, one for each of the categories I want to show. I call posts_nav_link before and after The Loop, but it shouldn’t execute unless there are more than 10 posts per page, since I’ve set the max number of posts per page to 10.

    The relevant code looks like this:

    <?php get_header(); ?>

    <?php posts_nav_link(...); ?>

    <?php query_posts('cat=5,8'); ?>

    <!-- execute The Loop -->
    <?php if(have_posts()) : ?>
    <?php while(have_posts()) : the_post(); ?>
    …loop stuff…
    <?php endwhile; ?>
    <?php endif; ?>

    <?php posts_nav_link(...); ?>

    The two posts (one from cat #5 and one from cat #8) display as expected, but posts_nav_link is called and shows a link to a second page…and then a third page. Essentially, I’ve got three copies of each post over three pages, instead of just one copy of each post on one page.

    I’ve looked over some other support threads but none of the solutions works. I’ve tried using this:

    <?php query_posts($query_string.'&cat=5,8'); ?>

    which eliminates the repeated posts, but not the call to posts_nav_link. If I click “Next Page” I just get a blank page.

    Am I calling query_posts in the proper location and in the proper way? I’d appreciate anyone’s help on this, since I’ve done my homework but haven’t been able to find a working solution.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Trouble with query_posts: multiple pages of repeated content’ is closed to new replies.