Pages

Friday, December 18, 2009

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



  • Random thougths of my blog



      $rand_posts = get_posts('numberposts=5&orderby=rand');
      foreach( $rand_posts as $post ) :
      ?>






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 .

No comments:

Related Posts Plugin for WordPress, Blogger...