Home | Contact | Help Center | Privacy Policy | Social Media Agency

August 23rd, 2009 | This post was viewed times.

How to show Random posts without using any WordPress plugins


Displaying the “Random posts” in your blog is the best ways to drag the users/ viewers attentions and hence helps in optimizing the bounce rates of your website. There are many plugins which display the random posts like Random Posts Widget ,Advanced Random Post ,Random Posts ,AJAX Random Posts ,Random Posts from Category ,Randomizer ,Random Featured Post and several others. Apart from these plugins you can also use light custom code to get the random posts which work on simple MySQL RAND() function to sort the random post using parameter values.

Code for displaying random posts in wordpress template

<ul>
  <li>
    <h2>Random thougths of my blog</h2>
    <ul>
      <?php
 $rand_posts = get_posts('numberposts=5&orderby=rand');
 foreach( $rand_posts as $post ) :
 ?>
      <li><a href="<?php the_permalink(); ?>">
        <?php the_title(); ?>
        </a></li>
      <?php endforeach; ?>
    </ul>
  </li>
</ul>

Note: You can use the above code anywhere in your wordpress templates. If you like this post then must go through the 101 List Of Awesome WordPress Tips and Resources .


Thanks for helping me
Share

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Similar Interesting Posts

Tutorials On

Designs

22 Responses to “How to show Random posts without using any WordPress plugins”

  1. How to show Random posts without using any #Wordpress plugins http://is.gd/2uWFp

  2. How to show Random posts without using any #Wordpress plugins http://is.gd/2uWFp

  3. How to show Random posts without using any WordPress plugins http://bit.ly/10yeHV

  4. nice article man…. keep up the good work
    .-= Shekhar´s last blog ..Professional .NET 2.0 Generics |Get the book for free =-.

  5. hey, nice code, just what I need, thank you

  6. How to show Random posts without using any WordPress plugins http://bit.ly/8boNHD

  7. How to show Random posts without using any WordPress plugins http://bit.ly/8boNHD #wordpress

  8. How to show Random posts without using any WordPress plugins http://bit.ly/8boNHD #wordpress

  9. Nice quick tip – RT @pkruvczuk: How to show Random posts without using any WordPress plugins http://bit.ly/8boNHD #wordpress

  10. wow only your code works on my blog thank you so much..

    check here:

    h++p://pspwallpaper.cz.cc/search/psp+wallpaper+cloud.html

  11. Hi! Yeah, like Indra said, only your code works! I tried 3 others and they don’t seem to work. Thanks!

  12. it shows the same post 5 times. not working for me.

  13. i have tried social media marketing for getting our new products to be known on the market. it seems to work well specially if the audience is targeted “

  14. i was a former employee and now i am making my best effort to start up a small business.*;.

Leave a Reply

Why ask?

    For Guest Blogging

    Honeytech Blog is open for guest blogging, you can apply now and become one of our proud authors.

    Follow @honeytech On Twitter

    More than 2999 people are watching this spreadsheet having list of all the "Android Tablets" http://bit.ly/9AMRu1
  • Sponsors Zone

  • Subscribe For Tips


  • Top Fans Of The Day

  • Mobile Applications

Top ↑

Hot Tags

google tips Web design Windows mobile open source Internet Firefox blogging Social mistakes browser Social media iphone Linux free WordPress Plugin ubuntu How to Designs