Advertisement
alchymyth

random thumbs

May 26th, 2012
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1. <?php
  2. //to show four random post thumbs
  3. $thumb_posts = new WP_Query(array(
  4. 'post_type' => 'post',
  5. 'ignore_sticky_posts' => 1,
  6. 'posts_per_page' => 4,
  7. 'meta_key' => '_thumbnail_id',
  8. 'orderby' => 'rand' ));
  9. if($thumb_posts->have_posts()) : ?>
  10. <div class="sub-post-thumbs">
  11. <?php while($thumb_posts->have_posts()): $thumb_posts->the_post();
  12. echo '<a href="' . get_permalink($post->ID) . '">' . get_the_post_thumbnail($post->ID,array(120,80)) . '</a>';
  13. endwhile; ?>
  14. </div>
  15. <?php endif;
  16. wp_reset_postdata();
  17. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement