• I am using query_posts to limit the number of posts on a page. However, the posts_nav_link doesn’t appear to allow the user to turn the page to look at previous entries. This is the following code, am I doing this correctly?

    <?php query_posts(‘cat=3&showposts=4’); ?>

    <?php while (have_posts()) : the_post(); ?>

    <div class=”post” id=”post-<?php the_ID(); ?>”>
    <h2><?php the_title(); ?></h2>
    <div class=”postdate”><?php the_time(‘F jS, Y’) ?> </div>
    <div class=”entry”>
    <?php the_content(‘Read the rest of this entry »’); ?>
    </div> <!– entry –>
    <?php endwhile; ?>

    <?php posts_nav_link(‘separator’,’prelabel’,’nextlabel’); ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • Does the posts_nav_link() tag work if you modify your query_posts() like this:

    <?php
    query_posts('cat=3&showposts=4&paged=1');
    ?>

    I ran into this yesterday, from the codex page on query posts:
    WordPress then ignores the other parameters it received via the URL (such as page number or category).
    Adding &paged=1 doesn’t seem to help.

    The following plugin may solve the issue, then. Set what category to show with the plugin, set number of posts to display from admin panel.

    http://dev.wp-plugins.org/file/front-page-cats/trunk/front_page_cats.php

    You have to customize it to affect a Page, instead of frontpage.

    Maybe use get_posts instead?

    <?php
    $posts = get_posts('numberposts=4&offset=0&category=3');
    foreach ($posts as $post) :
    ?>
    Your loop contents here
    <?php endforeach; ?>
    <?php posts_nav_link('separator','prelabel','nextlabel'); ?>

    Thread Starter marc0047

    (@marc0047)

    Doing the $posts as $post technique would have been really nice to use, but unfortunately it didn’t work. The ouput were posts with just the titles (but also as links to the actual story), and the navigation still failed to show up. But that’s still a good trick to know! Thanks!

    I’m also not keen on using the plugin because I’m creating these other pages by hand code as opposed to using WP’s Pages.

    ‘&paged1’ also unfortunately didn’t work.

    More suggestions would be great!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Can’t get the posts_nav_link to appear with query_posts’ is closed to new replies.