WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] query post order by parameters (10 posts)

  1. mhone
    Member
    Posted 3 years ago #

    Hi!
    I have a question about the query posts orderby parameters.
    I want my multi post pages to list the post in reverse chronological order, that means from the oldest to the most recent.
    I see that I need to set the value
    order=DESC
    http://codex.wordpress.org/Template_Tags/query_posts#Orderby_Parameters

    But I don't understand where?? What is the template where I need to set this value?

    Please help!

    Thank you

  2. mhone
    Member
    Posted 3 years ago #

    Sorry it means from the most recent to the oldest, of course

  3. vtxyzzy
    Member
    Posted 3 years ago #

    The template used is determined by the 'Template Hierarchy'.

    If you are not using a Static Front Page, and your theme has no home.php file, then the Home page will use index.php as the template.

    BTW, 'most recent to oldest' is the default behaviour in most themes, that is order='DESC' (older posts have LOWER dates). Perhaps your theme has an option to change the order.

  4. mhone
    Member
    Posted 3 years ago #

    But I am not talking about the homepage, I am talking about the category posts. The listing of posts in the category pages should be from the oldets (at the top) to the newest at the bottom. I checked, and there is no DESC option in my template (Atahualpa).
    The only solution seems to install a plugin, which I'd prefer to avoid if possible.
    Thanx

  5. vtxyzzy
    Member
    Posted 3 years ago #

    I just installed Atahualpa on my test site. You need to create an Archives Page, and set the category order there.

    Go to Admin->Atahualpa Theme Options->CREATE ARCHIVES PAGE and follow the instructions.

    EDIT: Sorry, that didn't work either!

  6. mhone
    Member
    Posted 3 years ago #

    Oh :(
    Well, thank you for trying!

  7. vtxyzzy
    Member
    Posted 3 years ago #

    Alright, I got it to work, but you will need to modify the theme. You probably should create a child theme so your changes will not get wiped out when you update the theme.

    There is probably a better way to do this, but this should work. In index.php, insert new lines above /* If there are any posts: */, like this:

    <?php if (is_category()) {
       query_posts(array_merge($wp_query->query,array('order' => 'ASC')));
       $bfa_ata['multi_next_prev_newer'] = '&laquo; Older Entries';
       $bfa_ata['multi_next_prev_older'] = 'Newer Entries &raquo;';
    }?>
    <?php /* If there are any posts: */
  8. mhone
    Member
    Posted 3 years ago #

    Hey! It works!
    Thank you very much, this has been very helpful :)

  9. vtxyzzy
    Member
    Posted 3 years ago #

    Glad it worked! Now, please use the dropdown at top right to mark this topic 'Resolved'.

  10. mhone
    Member
    Posted 3 years ago #

    Done. Thanks again

Topic Closed

This topic has been closed to new replies.

About this Topic