In WordPress some times you want to show recent posts in your blog. How to show them? To show recent posts we need to put some code in WordPress so that it shows the recent posts from your blog.

<?php $recent = new WP_Query("showposts=5"); while($recent->have_posts()) : $recent->the_post();?>
<li><a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a></li>
<?php endwhile; ?>
This will show a simple list of recent posts with the title of the post and a link to the post. It will show “5″ posts. To change the number you can change “5″ in the first line of this PHP code.
You can customize this list to give your own unique look.
<h3 align="center"><font color="#82CAFF">Recent Posts</font></h3>
<ul>
<?php $recent = new WP_Query("showposts=5"); while($recent->have_posts()) : $recent->the_post();?>
<li><a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a><br/><font size=2><i><?php the_date(' F j, Y'); ?></i></font></li>
<?php endwhile; ?>
</ul>
Here I have customized the recent posts look a little. I have added the title or heading “Recent Posts” above the list. This will show simple heading titled “Recent Posts”. You can change the font colour,font,size,etc.
Below the title I have added an extra piece of code that will show that when that post was published. Actually I’ve added that as it looks good in my theme. You may or may not add that. You can further customize this code and make give it your own unique look and feel.

Posted On February 8, 2010 At 1:14 PM
By
Posted In The Categories:
This Post Has Got 6 Comments







I use the default recent post from wordpress, but i think this article can give me an idea to customize it.
Yes customizing recent posts will make it look very good!
Its great to do most of the things by hand without adding more plugins! thanks for the codes bro
You’re welcome man! Codes are always better because they are just small and occupy less space.
Thanks for sharing the post. I wanna limit my plugin list. Hope this helps me
Thanks for commenting and you’re welcome! Yeah this will surely help you in limiting your plugins list. Looking forward to have you as one of my regular readers.