WordPress.org

Ready to get started?Download WordPress

Forums

Sort Posts in Ascending Order through wp_get_archives (6 posts)

  1. RJ_Dev
    Member
    Posted 3 years ago #

    Hello Everyone,

    I'm trying to show post titles ordered in a ascending order so the old posts show first, I used <?php wp_get_archives('type=postbypost&order=asc'); ?> which shows the post titles but displays them in descending order. I understand there are some plugins and also some wp_query codes that can be used to achieve this but I just thought there should be a simple way to do this and I don't see any reason why the above code shouldn't work. I would really appreciate it if someone could help me out here.

    Thanks,
    RJ_Dev

  2. jkovis
    Member
    Posted 3 years ago #

    Try wp_get_archives('type=alpha');

  3. RJ_Dev
    Member
    Posted 3 years ago #

    Thanks for helping out but I don't want to sort posts alphabetically, I want to sort it by date but in an ascending order so old posts will display first.

  4. fredsk2006
    Member
    Posted 2 years ago #

    Hello everyone,

    I'm having same exact problem. I want to sort the resulting sets by date in ascending order. Any work around for this?

    wp_get_archives() doesn't seem to support sort.

    Thanks,
    Fred

  5. larsjo
    Member
    Posted 2 years ago #

    Double post. Sorry.

  6. larsjo
    Member
    Posted 2 years ago #

    Here goes. This code snippet shows the 5 latest post titles in ascending order. By changing the number 5 in 'showposts=5' you can show any number of posts. (-1 shows all posts).

    <!-- LATEST POSTS START -->
    <?php query_posts('showposts=5&orderby=post_date&order=ASC'); ?>
    <ul>
    <?php while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
    <?php endwhile;?>
    </ul>
    <!-- LATEST POSTS END -->

Topic Closed

This topic has been closed to new replies.

About this Topic