How to add random featured post in wordpress

Welcome, Visitor. Subscribe to our RSS Feed and consider adding this article/site to your favorite social bookmark site if you find it useful. Thank you!

Do you  show random featured post on your Blog Home page or on your post? If you don’t the here is a reason why you should show random post on your blog. I was looking way to add random post in my blog.  Cause i wanted to show featured post to my blog readers. They can find about the tips and tutorials i wrote before in my blog. By doing this i got some more activity in my old Posts. It also helped me to get some more page views and extra visitors. I have a random post on my home page to show my old post to my blog readers.Here is the benefits to use random featured post:

1. If you get a lot of hits on your blog then you can rank high on search engines. If you get a high rank you can easily get lot of hits from Search engines.

2. You can show your Random post to readers.That means you get a chance to show your skills and  Products to your blog readers.

3. You can earn some Extra activity’s on your blog. If you run PPC Advertisement on your blog, More Hits and Activity Can earn Some revenue from PPC Advertisement.

You can do a whole bunch of things. Its easy to add random featured post. I use a plug-in called Random Featured Post to show random post. According to the plugin author, this plugin allows you to display a random post from a customizable category. This will draw attention readers to some of your best posts. The featured post will display the title ‘Featured Post’ (customizable) along with the post’s title, an excerpt and a link to continue to the full post.You can see my Index page (Index)  to  find out how it works. I also added a CSS border around the featured post. I am not good at CSS design. If you are good at CSS you can add some styles on your index page. Enough Chit chat lol.. To add this options on your blog follow this steps:

1. At first download the plugin from here. Then install and activate the plugin from admin panel.

2.  If you want to add random post on the top of your first post on you blog, then go to You WordPress theme editor and edit Main Index Template (index.php) to show random post.

 <?php if (have_posts()) : ?> 

And add this code before that line

 <?php show_featured_post(); ?> 

Ad that code on your blog where you want to show your Random post. However this will show all of your post randomly to the visitors. But you can customize that from plugin option page. you can also customize the code.This example will display the featured post only on your homepage inside a span block.

if ( function_exists('show_featured_post') )
 if (is_home() && !is_paged())
  show_featured_post('<span class="container">','</div>');

Or you can use code like this to display the featured post, ignoring the ‘Show Featured Post’ option and the category ID option in settings

if ( function_exists('show_featured_post') )
 show_featured_post('', '', true, 42);

3. You can edit CSS styles of your random post by adding and editing DIV class named “featuredpost”. As i said before i added a css box around the post. To add a css box like mine you can use this code

<div style="padding:5px; border:1px solid #E4F2FD; margin-top:10px;">
<?php show_featured_post(); ?>

Have fun adding random post on your blog.

Tags for the article:

    wordpress random post,random post wordpress


4 Responses to How to add random featured post in wordpress

  1. IndianCashMaker November 29, 2009 at 5:18 am #

    hey i want to display featured post in a box….where do i have to add the code you have shown in the example

  2. SELVA February 13, 2010 at 10:10 pm #

    Thanks very much for the code! Could have never gotten this Random Featured Post plugin up by myself! I used the code at the end and just made my border a bit thicker! It turned out nice! Again, thanks.

    • Jim February 13, 2010 at 11:04 pm #

      I am glad to see that you liked it…


  1. 250 Wordpress Tutorials - April 30, 2009

    […] 130. How to add random featured post in wordpress […]

Leave a Reply

eight + five =