Inspiration For Creative Minds
Home » Labs » Display Random Posts In WordPress  

Filed under Labs

Here is a block of code which will display posts as randomly in WordPress.This is one of the simple loop to show Random Posts In WordPress.

WordPress Code for Random Posts

query_posts(array('orderby' => 'rand', 'showposts' => 1));
if (have_posts()) :
while (have_posts()) : the_post(); ?>
<h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<?php the_content(); ?>
<?php endwhile;
endif; ?>
It's only fair to share...Share on Google+Tweet about this on TwitterShare on Facebook

Posts you may like: