WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] change order of posts - oldest first (11 posts)

  1. pbenj
    Member
    Posted 4 years ago #

    well done Allan Cole and WordPress - really enjoying this theme.

    My query:

    I'd like the oldest posts to appear first and the newest to appear last. is there any simple way of doing this?

    I'm relatively new to wordpress - appreciate your help on this...

    Thanks!

    PS apologies if this topic has already been covered - couldn't find it in the archives.

  2. MichaelH
    Member
    Posted 4 years ago #

    To resort the order of posts, using the WordPress Default theme for example, in the wp-content/themes/default/index.php file, just before this line, <?php if (have_posts()) : ?>, put this:

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

    The query_posts() article explains the arguments in detail.

  3. pbenj
    Member
    Posted 4 years ago #

    thanks for your speedy reply Michael!

    just tried it with the Default Theme and it works OK. Unfortunately, I can't get it to work with the Autofocus Theme. I'll read the query_posts() article - maybe I'll find something there...

  4. pbenj
    Member
    Posted 4 years ago #

    I've tried again but no success. the line in the Autofocus Theme looks a little different to the one above:

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

    any ideas what else I could try?

  5. MichaelH
    Member
    Posted 4 years ago #

    Put

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

    right before

    <?php while ( have_posts() ) : the_post() ?>
  6. pbenj
    Member
    Posted 4 years ago #

    Thanks Michael. I have added that line exactly as you've described but it only worked with the WordPress Default (and other similar) themes. the Autofocus Theme
    remains completely unchanged by that bit of code. have also tried deleting cache and using different browsers...

  7. MichaelH
    Member
    Posted 4 years ago #

    Why you would want to do that with that theme...:)

    Anyways, that theme uses home.php to display those posts so make the change there.

  8. pbenj
    Member
    Posted 4 years ago #

    I'd like to use it to present a photo essay. I've taken out the dates, set reading to show 4 posts per page and now it'd be nice to advance through the story by going 'forwards' as it were and not by clicking on the link "older posts" down on the left. hope that makes sense ;-)

  9. pbenj
    Member
    Posted 4 years ago #

    could try switching the nav links I suppose?

  10. ficarro
    Member
    Posted 4 years ago #

    Just wanted to thank you MichaelH. I've been looking for the same thing and other code didn't work (possibly because they were for older versions of WP or a basic theme). Your code worked perfect and is exactly what I needed.

  11. mrcycling
    Member
    Posted 4 years ago #

    Has anyone been able to get this to work with AutoFocus ? I have tried the above suggestions to no avail with this theme. The theme was used for a photoblog from a bike tour and now that the tour is over, it would be nice to display posts from the beginning so folks can follow the trip in order, not backwards. The website is: http://cycling-to-everest.thebiergarten.com .

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags