Code: How to Display Recent Posts in WordPress
June 19th, 2009
Code Snippets, WordPress Tutorials
Although most current WordPress installations include a widget for displaying recent posts, there are quite a few people that prefer to get their hands dirty and manually code things. If you’d like to learn how to display recent posts in WordPress, you’ve come to the right place!
Here is the code you’ll need to display recent posts. Simply copy the following code and place it in your sidebar.php file where you want the recent posts to be displayed!
<?php query_posts('showposts=5'); ?>
<ul>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
</ul>

