Here ya go.. the proper way to do it ><
For use as the main or only loop:
PHP Code:
<?php
$args1 = array(
'posts_per_page' => 5,
'orderby' => 'rand',
'post_status' => 'publish',
'offset' => 0
);
query_posts($args1);
if (have_posts()) : while (have_posts()) : the_post(); ?>
<li>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p><img src="<?php echo get_post_meta($post->ID, thumbnail, true); ?>" width="100" height="100"></p>
</li>
<?php endwhile; endif; ?>
Use this as a secondary loop on a page with multiple loops... will save some resources by using the initial query from the main loop as opposed to creating a new query:
PHP Code:
<?php
$args2 = array(
'posts_per_page' => 5,
'orderby' => 'rand',
'post_status' => 'publish',
'offset' => 0
);
$rand_posts = get_posts($args2);
foreach ($rand_posts as $post) : setup_postdata($post); ?>
<li>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p><img src="<?php echo get_post_meta($post->ID, thumbnail, true); ?>" width="100" height="100"></p>
</li>
<?php endforeach; ?>