Home > Blogs, Bookmarks, PhP, Tech, Wordpress > Wordpress Random Posts – get_posts() function

Wordpress Random Posts – get_posts() function

December 21st, 2008 Leave a comment Go to comments

Wordpress Random posts

Display a list of posts selected randomly by using the get_posts() function for the orderby parameter value:

<h2>Random Post</h2>
 <ul>
    <?php $rand_posts = get_posts('numberposts=10&orderby=rand'); ?>
    <?php foreach( $rand_posts as $post ) : ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
 </ul>
  1. No comments yet.
  1. No trackbacks yet.
GoCache - ByREV-Cache v1.0 - live served in : 0.154503 sec (gzip)