Forums

how make category archive posts in reverse-chronological order (5 posts)

  1. yogidevotee
    Member
    Posted 8 months ago #

    Hello,
    I have a twenty ten theme, and am trying to have the order of posts in the category archives in reverse-chronological order (earliest posts first)
    I want to do this just for category archives and not globally.

    Any ideas?

    Thanks much!

  2. esmi
    Theme Diva & Forum Moderator
    Posted 8 months ago #

    Do not edit the Twenty Eleven theme. It is the default WordPress 3.2 theme and having access to an unedited version of the theme is vital when dealing with a range of site issues.

    Create a child theme for your customisations. Once your child theme is active, see Category_Templates and query_posts.

  3. Digital Raindrops
    Member
    Posted 8 months ago #

    Create a child theme for twenty ten, then copy across loop.php to the child theme, rename the copied file loop-category.php

    Open the file and before these lines:

    <?php /* If there are no posts to display, such as an empty archive page */ ?>
    <?php if ( ! have_posts() ) : ?>

    Add a line to reverse the sort order!
    <?php query_posts($query_string . "&order=ASC"); ?>

    So you have:

    <?php /* Reverse the sort order ascending */ ?>
    <?php query_posts($query_string . "&order=ASC"); ?>
    
    <?php /* If there are no posts to display, such as an empty archive page */ ?>
    <?php if ( ! have_posts() ) : ?>

    Twenty Ten Child Theme:
    If you want to make it better and category specific, or do not want to code it yourself, I have already posted about this and there is a child theme, I use it for a series of posts like, part 1, part 2 etc:

    So if you have no other changes, job done!

    Twenty Eleven Child Theme (Page of Posts):
    This variation uses Custom Fields, and is a template page rather than index.pgp or category.php, and is for twenty eleven.

    HTH

    David

  4. yogidevotee
    Member
    Posted 8 months ago #

    Thank you both so much!
    I will try that.

    thanks.

  5. yogidevotee
    Member
    Posted 8 months ago #

    actually, when I do that, the sort order is reversed successfully, however any category archive page shows ALL posts.
    Was I also supposed to copy across anything else other than style.css and loop.php to the child theme?

    thanks!

Reply

You must log in to post.

About this Topic