WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Would LIKE to Reverse the Order of "Recent Posts" List (6 posts)

  1. trivum
    Member
    Posted 5 years ago #

    I would like to reverse the order of my "recent posts" list in the side bar so that they appear in the original order written -- i.e. have the first post written (the oldest) appear at the top of the list instead of at the bottom.

    Any ideas how to do this? Thanks.

  2. Dagon Design
    Member
    Posted 5 years ago #

    Can you show us the code you are using to generate this list?

  3. trivum
    Member
    Posted 5 years ago #

    Here's the code:

    <?php wp_get_archives('type=postbypost&limit=10'); ?>

    I was actually able to do what I wanted with the post from a category by putting "&order=asc" into the code, but when I do that with the wp_get_archives it doesn't seem to work. Here's the code I used that does what I want it to do with the categories.

    <?php
    $posts = get_posts('numberposts=10&order=asc&category='. $category->term_id);
    foreach($posts as $post) :
    ?>

    I'm wondering if I could use the above code but call all the posts and not just the ones from that particular category.

  4. Dagon Design
    Member
    Posted 5 years ago #

    Yes.. just remove the category declaration in the function

  5. trivum
    Member
    Posted 5 years ago #

    Great - that did it. Thanks a lot Dragon.

    Final code for anyone else who comes along:

    <?php
    $posts = get_posts('numberposts=10&order=asc');
    foreach($posts as $post) :
    ?>
  6. jarom1
    Member
    Posted 5 years ago #

    I'd like to do this, but in the main content section (i.e. someone clicks on a category and the posts appear with the oldest post on top).

    The code currently looks like this:

    <?php while (have_posts()) : the_post(); ?>
    		<div class="post"><h3 id="post-<?php the_ID(); ?>"><a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    		</div>
    <?php endwhile; ?>

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.