Support » Fixing WordPress » Chronological sidebar archives

  • Resolved Gohst


    I’ve been looking all over for some way to make my sidebar archives chronological. At the moment they are reverse chronological. Eldest post near the bottom of the screen and most recent at the top. I’d like it to be reversed so that the oldest post is at the top and the newest is at the bottom.

    So far I’ve got this in the sidebar.php file

    <!-- START ARCHIVES -->
    <?php wp_get_archives('type=postbypost') ?>
    <!-- END ARCHIVES -->

    Try as I might, I can’t figure how to get them to reverse the order in which they display. I’ve read heaps of confusing posts here in the forum, which mostly seemed to be asking something else. I read the support page on wp_get_archives where it said you can make it alphabetical, but it didn’t say how, so there was no way for me to go “ok, ill need to do ‘this’ to make it chronological”. Any help which can offer a reasonable solution to my simple request would be very, very appreciated. Thankyou in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I read the support page on wp_get_archives where it said you can make it alphabetical

    Where does it say that *exactly*. If it does, it’s wrong and needs to be corrected.

    get_archives/wp_get_archives can only display posts in chronological order, from latest to earliest. It does not offer a parameter to change the sort to ascending order. For that you can try using something like get_posts() in a way that duplicates the output of get_archives(), like:

    $arcposts = get_posts('numberposts=-1&orderby=post_date&order=ASC');
    foreach($arcposts as $post) :
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>

    Note: Setting numberposts to a value of -1 (minus 1) tells WordPress to collect all posts.

    Well, I don’t know if it says it *literally* but that’s what I got from it. Its over here: and where it says “Displays archive list of the last twenty most recent posts listed by post title.” the phrase “…by post title” means alphabetically to me.

    I’ll try out your code by the way.
    [edit] the -1 thing didn’t work, got an error. So I just changed it to 20000. Figure that should keep me safe.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Chronological sidebar archives’ is closed to new replies.