WordPress.org

Ready to get started?Download WordPress

Forums

Problem with reversing post order - nav links wrong (11 posts)

  1. TrishaM
    Member
    Posted 5 years ago #

    I have one category for which I need to reverse the post order so that they appear ini chronological order - I did this by creating a template page adding this line before the Loop:

    <?php query_posts('cat=8&order_by=date&order=ASC'); ?>

    However, since there are more posts than can appear on one page, the navigational links appear at the bottom, but do not work correctly. One the first page, I only get "previous entries", which is supposed to go to page two, and it does indeed load what it thinks is page 2, but it's really the same page again. At this point it has both links (previous entries and next entries) but both links just keep loading the same 10 posts - it never goes to what would be the next 10 posts in order.

    Any suggestions?

  2. TrishaM
    Member
    Posted 5 years ago #

    Have spent the last couple of days searching the forums for a solution to no avail. The best I can find is some vague references to "fixes" as in this post:

    http://wordpress.org/support/topic/179592?replies=5

    (I'll quote to save you the time of reading it)

    Search the forums. By default a custom query breaks the next/prev navigation.

    There were quite a number of posts suggesting different fixes.

    Unfortunately there are no specific links to other (resolved) posts or docs in the Codex, so I have no idea what a fix for this problem might be. And I have searched to Forums extensively and still not found a fix.

    I have tried everything, but no matter what I do if I specify an Ascending sort (in chronological date order instead of "newest first" order of a typical blog), the next/prev nav links break and just keep displaying the same page over and over again.....it seems to me that specifying a sort order should not constitute a "custom query" that would break the nav links....

    Can someone please point me in the right direction to find one of these vaguely referenced fixes?

  3. TrishaM
    Member
    Posted 5 years ago #

    Bump........I still need help with this one......none of the suggestions I found in this forum apply to this situation (I am not using showposts as several other people have recommended having it set to the same number of posts as in the blog settings)...all I am doing is setting the order= to ASC instead of what would be the default, DESC...

    If anyone wants to take a look here is a link to the page:

    http://www.walkingcarrot.com/need-to-catch-up/

    This page is for people who have not been following along on the daily trip journals and want to read them starting with the first post, in chronological order.

    I have tried using the new
    <?php posts_nav_link(); ?>
    as well as the older
    <?php previous_posts_link('&laquo; Older Entries') ?><?php next_posts_link('Newer Entries &raquo;') ?>
    and I've also tried the excellent plugin from GamerZ, wp_pagenavi, but all give the same results - all links will only show the same XX posts over and over again even though WP "thinks" it is going to the next page.

    Please help - anyone?

  4. TrishaM
    Member
    Posted 5 years ago #

    I'm having a hard time understanding how it is that something as simple as reversing the display order can break the next/prev page links and no one thinks that this is important. In two days not one person has come up with a suggestion or fix. Does this mean that it can't be fixed?

    Am I missing something? I've been to a couple of WordCamps and talked to a number of WP gurus who all tout WP as having grown "beyond simple blog software", and they are right. It is a brilliant CMS platform that is used on a wide variety of sites that are not "typical" blogs.

    Surely there must be people who want posts shown in chronological order (the opposite of the default display), and yet who still need the previous page / next page links to work correctly..........

  5. TrishaM
    Member
    Posted 5 years ago #

    Bump.......

  6. iridiax
    Member
    Posted 5 years ago #

    Try using code like in Example 3 on the query_posts codex page with something like posts_per_page=6 instead of -1:

    http://codex.wordpress.org/Template_Tags/query_posts#Example_3

  7. TrishaM
    Member
    Posted 5 years ago #

    Hello iridiax

    Thank you very much for responding- I am sincerely grateful for the suggestion - but this did not work either. I had tried "&showposts=4" and made sure the number matched my blog settings, and just tried this one ("&posts_per_page=4") with the number matching my blog settings, with the same results. The nav links (next page / previous page) still just keep showing the same 4 posts even though it says /pg/2 or /pg/3 etc......

    Any other ideas?

  8. iridiax
    Member
    Posted 5 years ago #

    Did you add the $query_string part and then use posts_nav_link()?

    <?php
    query_posts($query_string.'posts_per_page=4&cat=8&order_by=date&order=ASC');
    while(have_posts()) { the_post();
    <!-- put your loop here -->
    }
    ?>
  9. TrishaM
    Member
    Posted 5 years ago #

    Although I had been using posts_nav_link(); I did not have the $query_string. in my query_posts statement, so I just tried it now as suggested (I copied and pasted from above), but alas, it had no effect :( - same results as before, and I was really hoping that might be it......

    HOWEVER, in sheer frustration I have removed ALL of the parameters and am JUST doing a straight "if (have_posts()): while (have_posts()): the_post();"....followed by the loop - just a straight archive page with the default parameters.....

    And STILL the nav links are broken - whether I use the old nav links or the new one, it STILL just shows the same posts over and over......

    SO all this time I thought that trying to make the posts appear in chronological order was breaking the nav links, when in reality they just plain don't work.

    To test this I added the nav links (testing both old style and new style) to my index.php page, and they still would only show the same posts over and over again - even though WP thought it was going to the next or previous pages, it still displayed the same posts.

    SO is there a fix for the broken nav links? Anyone?

  10. TrishaM
    Member
    Posted 5 years ago #

    Here is more information that may help someone to help me:

    This is set up as a Page with a custom template in order to achieve the reverse order (ASC) in order to display posts in chronological order, using this line of code before the Loop:

    <?php query_posts('cat=8&order_by=date&order=ASC'); ?>

    However, since it is a Page instead of a normal Archive/Category page (even though I'm limiting posts to one category) I believe that this is what is breaking the prev/next posts nav links. Unfortunately I don't know how to show an alternate category page for a category that will reverse the order, not without adding another category and going back and adding that category to all of those posts - not a good option - so I've tackled this in a totally different manner but still need help......

    After combing thru the forum for days I came up with this instead:

    <?php
     $lastposts = get_posts('numberposts=0&category=8&order_by=date&order=ASC');
     foreach($lastposts as $post) :
        setup_postdata($post);
     ?>

    However, this will not paginate - it shows all posts on one VERY long page - which is not ideal.

    Is there any way to achieve a listing of all posts in a single category, in ASC order, and have it paginated?

    Thanks for any ideas anyone can offer.......

  11. solidhex
    Member
    Posted 4 years ago #

    I think the above sample was missing an '&'

    <?php
    query_posts($query_string.'posts_per_page=4&amp;cat=8&amp;order_by=date&amp;order=ASC');
    while(have_posts()) { the_post();
    <!-- put your loop here -->
    }
    ?>

    I think should be:

    <?php
    query_posts($query_string.'&amp;posts_per_page=4&amp;cat=8&amp;order_by=date&amp;order=ASC');
    while(have_posts()) { the_post();
    <!-- put your loop here -->
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.