Forums

[resolved] Arranging posts by date ascending (3 posts)

  1. howardhuhn
    Member
    Posted 6 years ago #

    I need to know how to arrange posts in a category by ascending date (earliest on top of page/latest on bottom - i.e. the opposite of the default date arrangement) Any ideas?

  2. leflo
    Member
    Posted 6 years ago #

    You could use following code:

    <?php
    add_filter('posts_orderby', 'action_order_ascending');

    function action_order_ascending($orderby)
    {
    return 'post_date ASC';
    }
    ?>

    untested, but WordPress source says that it will work.

  3. howardhuhn
    Member
    Posted 6 years ago #

    Didn't get that to work, but I did figure it out, adjusting the Alphabetizing Posts script, I did the following
    <?php
    $posts = query_posts($query_string .
    '&orderby=date&order=asc&posts_per_page=-1');
    if (have_posts()) : while (have_posts()) : the_post(); ?>

    This worked just fine.

Topic Closed

This topic has been closed to new replies.

About this Topic