Top 3 Ways of Showing Recent Posts in WordPress Code Theme or Sidebar

image Displaying recent posts in your WordPress is a norm nowadays on every other WordPress or Blogger blog, Now you can use any of these codes / methods to get yourself a nice recent posts list for last 10 “X number of posts “ .

1. Recent Posts Using the wp_get_archives function

<?php wp_get_archives(‘title_li=&type=postbypost&limit=10′); ?>

 

This would list recent 10 posts , in their own <li> tags , you can use this after post-meta or the_content () in single.php to list recent posts after every Post , or use it in any of your Sidebars.

 

2. Recent Posts Using the WordPress query function to query the Posts database 

<?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>

This piece of code can be used anywhere in your theme , as it is self sufficient and it will display recent 5 posts, change the value of “showposts=5” variable to whatever no. of posts you want

3. Recent Posts widget / Plugins for the novice and beginners

If you are a noob at wordpress and still want to get the recent posts functionality , then try the various plugins available to do the work for you. You  can use any of these ..

http://wordpress.org/extend/plugins/search.php?q=recent+posts

OR Use the Add plugin option in your WordPress Dashboard, and search for recent posts  and you can install the plugin from their directly and easily .

Out of the 3 mentioned above I would recommend using first 2 , as they give you more control but only if you know some PHP and programming , otherwise go for the plugins ( it’s the easy way out ! ).

  • Share/Bookmark

Leave a Reply

You Searched It

wordpress query recentposts (5) (5)wp_get_archives title_li (2) (2)wp_get_archives variable (2)wordpress post query generator mac (1)wordpress display recent posts with javascript -twitter -tweet -tweets (1)$recentPosts->query(showposts=3 (1)wordpress ?php query show recent post (1)wordpress query post from top domain (1)wordpress query posts using meta (1)wp_get_archives images (1)wp_get_archives Split into Two Columns (1)wp_get_archives(title_li=&type=postbypost&limit= (1)showing recent posts (1)recent posts widget wordpress more control (1)recent posts widget wordpress javascript (1) (1) top posts (1)how to display image in recent post (1) 54 views