You Are Here:- Home / Wordpress / How To Display Recent Posts In WordPress?

How To Display Recent Posts In WordPress?


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.


If You Enjoyed Reading This Post, Please Consider To Leave A Comment And / Or Subscribe To The Feed And Get Future Articles Delivered To Your Feed Reader Regularly.

Related Posts


6 Responses to “How To Display Recent Posts In WordPress?”

Comments

  1. I use the default recent post from wordpress, but i think this article can give me an idea to customize it.

  2. Its great to do most of the things by hand without adding more plugins! thanks for the codes bro :D

  3. Blog4Boys says:

    Thanks for sharing the post. I wanna limit my plugin list. Hope this helps me

    • Saksham T says:

      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.

Leave A Reply

CommentLuv Enabled

Copyright © 2009 - 2010 Blogging Junction. All Rights Reserved.
Blogging Junction Is Proudly Powered By Wordpress And Blog Design By New WP Themes