Advertisement
alchymyth

comments' thumbs

Mar 29th, 2012
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. <?php $args = array(
  2.         'status' => 'approve',
  3.         'number' => '12');
  4.         $comments = get_comments($args);
  5.         foreach($comments as $comment) {
  6.        
  7.         $post_id = $comment->comment_post_ID;
  8.         $post_thumb_id = get_post_thumbnail_id($post_id);
  9.         $post_attachment_src = wp_get_attachment_image_src( $post_thumb_id, 'medium');
  10.         $post_thumb_url = $post_attachment_src[0];
  11.  
  12. ?>
  13.  
  14.         <div class="hb-comment" style="background: url('<?php echo $post_thumb_url; ?>');">
  15.         <h5><?php echo($comment->comment_author);?></h5>
  16.         <p><?php echo substr($comment->comment_content,0,50);?></p>
  17.         </div>
  18.  
  19.         <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement