WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] query post order by parameters

[Resolved] query post order by parameters

  • 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

Viewing 9 replies - 1 through 9 (of 9 total)
  • Sorry it means from the most recent to the oldest, of course

    vtxyzzy

    @vtxyzzy

    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.

    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

    vtxyzzy

    @vtxyzzy

    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!

    Oh 🙁
    Well, thank you for trying!

    vtxyzzy

    @vtxyzzy

    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: */

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

    vtxyzzy

    @vtxyzzy

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

    Done. Thanks again

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] query post order by parameters’ is closed to new replies.
Skip to toolbar