
random thumbs
By:
alchymyth on
May 26th, 2012 | syntax:
PHP | size: 0.51 KB | hits: 70 | expires: Never
<?php
//to show four random post thumbs
$thumb_posts = new WP_Query(array(
'post_type' => 'post',
'ignore_sticky_posts' => 1,
'posts_per_page' => 4,
'meta_key' => '_thumbnail_id',
'orderby' => 'rand' ));
if($thumb_posts->have_posts()) : ?>
<div class="sub-post-thumbs">
<?php while($thumb_posts->have_posts()): $thumb_posts->the_post();
echo '<a href="' . get_permalink($post->ID) . '">' . get_the_post_thumbnail($post->ID,array(120,80)) . '</a>';
endwhile; ?>
</div>
<?php endif;
wp_reset_postdata();
?>