WordPress.org

Ready to get started?Download WordPress

Forums

chronological posts stuck on page 1 (6 posts)

  1. jgjertsen
    Member
    Posted 7 years ago #

    I have a category set up which I want to display chronologically. To accomplish this, I created a category-5.php, which is identical to index.php, except it has:

    <?php
    query_posts('order=ASC');
    ?>

    at the top. Works like a charm. Except for when I use the navigation links at the bottom:

    <div class="alignleft"><?php posts_nav_link('','&laquo; Previous Entries','') ?></div>
    <div class="alignright"><?php posts_nav_link('','','Next Entries &raquo;') ?></div>

    and arrive at a URL like:
    http://www.sweetbabyjames.info/wordpress/?cat=5&paged=2

    it is still the first three posts (not the next three, as I was expecting). Somewhat of a newbie, but I can write PHP and I thought I understood the way the loop worked. How do I get the paging to word correctly with ASC? Help, please!

  2. MichaelH
    Member
    Posted 7 years ago #

    Seems like there's an ambiguity (see Template_Tags/posts_nav_link) when you are sorting post in ascending (oldest first) order.

    I can't swear to it, but maybe the Custom Query String plugin might solve your problem.
    http://drunkenmonkey.org/user/archive/custom-query-string-2.6.zip

  3. gjertsen
    Member
    Posted 7 years ago #

    Ok, I've installed and activated the custom query string plugin, but that didn't seem to help; is there something more I need to configure?

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Change your query_posts call to this:

    <?php
    query_posts($query_string . '&order=ASC');
    ?>

    Done and done. No need for any weird plugins.

    There's no ambiguity involved here. You're just failing to pass the query_string into the query_posts call. Without that, there's no way for query_posts to know that you want page 2 of the posts, for example.

  5. gjertsen
    Member
    Posted 7 years ago #

    Thanks, Otto42... works like a charm!

  6. laslo
    Member
    Posted 6 years ago #

    yay! thanks Otto42.
    I've read in other threads that query_posts will break paging.
    It did in my blog, but then I added query_string and it fixed! =D

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.