Home » Labs » How to display random blog post on WordPress  

How to display random blog post on WordPress


Filed under Labs

Add below code to your WordPress theme and it will display posts on random wise. You need to edit the category in below code according to your need.

 
	<?php 
		query_posts('showposts=10&cat=5&orderby=rand');
		while ( have_posts() ) : the_post(); 
	?>	
 
		<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
			<h2><?php the_title(); ?></h2>
		 </a>		
		<?php the_excerpt();?>
 
	<?php endwhile; ?>
It's only fair to share...Share on Google+Tweet about this on TwitterShare on Facebook

Posts you may like: