View Single Post
Old 06-04-2013, 12:38 PM  
alcstrategy
Confirmed User
 
Industry Role:
Join Date: May 2012
Posts: 124
as with anything there's many ways to skin a cat, but there's an example in wordpress docs here: http://codex.wordpress.org/Template_Tags/get_posts

numberposts is the number of posts you want
orderby is rand which is equiv to mysql rand() which is random num

the docs show other parameters you can use also

i guess you could put this in page.php, although I guess it depends where you want it, etc, but i just posted general example


<ul>
<?php
$args = array( 'numberposts' => 5, 'orderby' => 'rand' );
$rand_posts = get_posts( $args );
foreach( $rand_posts as $post ) : ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>

Last edited by alcstrategy; 06-04-2013 at 12:40 PM..
alcstrategy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote