• Resolved drphil9001

    (@drphil9001)


    I have a separate blog template (blog.php) to show posts in my blog and a static home page (home.php) that seems to be working. However, as I was testing the paging of multiple posts, I noticed that the navigation links within The Loop do not show up properly when I reduce the number of posts shown on a page.

    Here is how I am setting up The Loop on blog.php

    <?php $blog_query = new WP_Query('posts_per_page=1'); ?>
    <?php if ($blog_query->have_posts()) : ?>
    
    <?php while ($blog_query->have_posts()) : $blog_query->the_post(); ?>

    After the endwhile I have the following to setup the navigation links to the next page:

    <div class="navigation">
    <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    </div>

    When I view my blog page, I see a single post, but the navigation links do not show up. All that is there are empty div tags.

    I have also tried to replace the instantiation of WP_query class with a query_posts() call, but when I do that the blog.php page stops rendering at the point of the call to query_posts().

    How can I display the navigation links?

    Thanks.

Viewing 1 replies (of 1 total)
  • Thread Starter drphil9001

    (@drphil9001)

    I finally found the problem. It appears as though there is a bug when you have a template and a WP Page with the same name that uses query_posts() and next_post_links() or previous_post_links().

    WP gets confused and those links are broken.

    A simple rename of the template (not the file name, but rather the template name in the file comments) fixes the problem.

Viewing 1 replies (of 1 total)
  • The topic ‘Query Posts and Navigation’ is closed to new replies.