get a random post in wordpress using php
October 17th, 2010 by Lawrence David
to get a random post from your wordpress blog, use this little php snippet:
<?php
$rand_posts = get_posts(‘numberposts=1&orderby=rand’);
foreach( $rand_posts as $post ) :
?>
<a href=”<?php the_permalink(); ?>”>Chance</a>
<?php endforeach; ?>