WordPress.org

Ready to get started?Download WordPress

Forums

Display only One Category in Reverse Order (5 posts)

  1. Tranny
    Member
    Posted 5 years ago #

    I have figured out that by adding following line before the loop:

    <?php get_header(); query_posts($query_string . "&order=ASC"); ?>

    category posts get displayed in reverse chronological order. I was trying to figure out how to make only posts in ONE (select) category display in reverse chronological order and have the rest from last to first, but that's beyond my skill. I tried searching for answers big time but wasn't able to find the solution. Somebody please help :)

  2. MichaelH
    Member
    Posted 5 years ago #

    Assumptions: category 4 post in post date ascending order, otherwise do not need to change the query!

    <?php
    get_header();
    if (is_category('4') ) {
    query_posts($query_string . '&order=ASC');
    }
    ?>
  3. Diarmuid
    Member
    Posted 5 years ago #

    Works a treat, thanks.

  4. ridewithjoe
    Member
    Posted 5 years ago #

    This is exactly what i need as well... but where do I post the code? Which file?

  5. MichaelH
    Member
    Posted 5 years ago #

    With the help of the Template Hierarchy article, determine what Template is displaying your posts (likely index.php or category.php) and put the code there. Watch out though, the answer used some of the code that Tranny described...

    Also might consider using the Query Posts Reloaded plugin.

Topic Closed

This topic has been closed to new replies.

About this Topic