• wiredkiwis

    (@wiredkiwis)


    Can this be done in WP?
    I have a blog set to posts paged but I want the posts to show the oldest first.
    Have hunted but cannot find a mention of it.
    Anyone like to point me in the right direction?

Viewing 3 replies - 16 through 18 (of 18 total)
  • I had the same problem but found the solution here: https://codex.www.ads-software.com/Template_Tags/query_posts

    There is no need to change any core files. Just insert this code right above your loop, and change the variables to suit your needs.


    $categoryvariable=$cat; // assign the variable as current category
    $query= 'cat=' . $categoryvariable. '&orderby=date&order=ASC'; // concatenate the query
    query_posts($query); // run the query

    works perfectly every time.

    <?php
    $categoryvariable=$cat; // assign the variable as current category
    $query= ‘cat=’ . $categoryvariable. ‘&orderby=date&order=ASC’; // concatenate the query
    query_posts($query); // run the query
    ?>

    When I look at this I don’t understand which part I’m supposed to replace with the title of the category that I want changed. Can someone please help me?

    stairway, thanks for pointing me to the right direction! The code you have posted doesn’t behave with paging. That is, I couldn’t get posts 11-20 to show up on page 2.

    My solution is to add this code above The Loop:

    query_posts($query_string."&order=ASC");

    This will make all of the posts in all of your categories ordered to show the oldest post first and the newest post last.

    To reverse order of posts in only one category use this:

    <?php if ($cat==x) {query_posts($query_string."&order=ASC"); } ?>

    Where x in $cat=x is the category ID number.

    Note: if you still don’t know what The Loop is, it starts with this line:

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

    The query_post should be ABOVE this line.

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘Reverse order posting’ is closed to new replies.