Support » Fixing WordPress » Reverse order of posts in a category

  • Hi,

    By default posts in a category are shown in the descending order by date. That is what you post last is shown first on the category page.

    I need to reverse this order ONLY in one category of my site. Reason – publishing an e-book section on the site. We start posting the books like – preface, introduction, page1, page2, page3… and so on.

    The category index shows:


    I would like it to come up as


    and so on.

    I do not want to touch the general sort order as rest of the site has articles which should come up in the default sort order. I need to alter the sort order for just one category. How can I do this?

    Your help would be much appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • doctorb,

    Here is one option:

    if ( have_posts() ) : while ( have_posts() ) : the_post();

    Order Parameters:
    Designates the ascending or descending order of the ORDERBY parameter.

    * order=ASC – ascending order, lowest to highest value
    * order=DESC – descending order, highest to lowest value

    For more information look through the codex here:

    Thanks for your reply. I solve dthis by adding:

    <?php if (is_category(array(56,57))){
    query_posts($query_string . “&order=ASC”);} ?>

    Before this line
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    One can add the number of categories in the array of which they want to reverse the post order.

    Why not just artificially set the dates of subsequent postings to be further back in time?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Reverse order of posts in a category’ is closed to new replies.