WordPress.org

Support

Support » How-To and Troubleshooting » Display 5 Recent Entries

Display 5 Recent Entries

  • I searched and found nothing useful, so here goes: How do I plug the last 5 posts I made into my sidebar?

Viewing 15 replies - 1 through 15 (of 19 total)

scap that, it seems to be wrong:

  • 5 Newest Posts:
      <?php $latest = new WP_Query(‘showposts=5’);
      while ($latest->have_posts()) : $latest->the_post(); ?>
      <?php
      $title = get_the_title();
      if (strlen($title) >= 35)
      $title = substr($title, 0, 35) . ‘…’;
      ?>

    • “><?php echo $title; ?>
    • <?php endwhile; ?>

  • darn it, just get it here: http://randomfire.fierymill.net

    It’s also pretty easy to use wp_get_archives with type parametre set to ‘postbypost’ and limit to 5 (or so). There is even an example of this use on the template tag page (in Codex).

    Of course, that doesn’t limit the title length.

    err, ok, the easy way is like this though 🙂

    <?php get_archives('postbypost', 5, 'html', '', '', false) ?>

    its a holdover from 1.2.* that seems to be working on my 1.5 blog

    edit: yeah, what minna said! 🙂

    OK, Is there a way to add the latest entries to only the stories when you click read more? As you see in mine, the latest entries are showing on the index on every post.

    I use a hack you can find here

    does that work with 1.5?

    fro, you got already the code, so you don’t really need that hack… you just inserted the code in the wrong place.

    where do i insert it at?

    i tried a ton of places

    In the my-hacks.php that you probably don’t have and have to create with the hack in it. And then upload it to, if memory serves, the root directory you have WordPress installed to. Oh, and you have to go to one of the Options panels and activate it…I can’t remember where off the top of my head, but it is called the my-hacks legacy….

    But this is a LOT of work. Do you have something against plugins?

    Customizable Post Listings plugin makes this SO EASY. Just activate it and put the following in your sidebar:

    <li id="recent"><?php _e('Recent Articles'); ?><ul>
    <?php c2c_get_recent_posts(5); ?></ul></li>

    or customize the title or whatever to fit your own sidebar.

    And check out http://codex.wordpress.org/Customizing_Your_Sidebar

    ok – but replying to moshu – where do i put the code?

    where do you want the 5 to appear?

    When I click the permalink – I want it only to show up right under the body and just above the comments – no where on the main page should it show up

    Viewing 15 replies - 1 through 15 (of 19 total)
    • The topic ‘Display 5 Recent Entries’ is closed to new replies.
    Skip to toolbar