Posted By

warrenonline on 11/15/09


Tagged

wordpress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

ef


Wordpress Comments Loop


 / Published in: PHP
 

URL: http://warrenonline.ca

Just the basic Wordpress comments loop.

  1. <!-- recent comment of each post -->
  2.  
  3. <div class="recent-comment">
  4. <?php
  5. $comment_array = array_reverse(get_approved_comments($wp_query->post->ID));
  6. $count = 1;
  7. ?>
  8.  
  9. <?php if ($comment_array) { ?>
  10. <span class="comment"> <?php comments_number('No comment','1 comment','% comments'); ?></span> - Latest by:
  11. <ul class="commentlist">
  12. <?php foreach($comment_array as $comment){ ?>
  13. <?php if ($count++ <= 2) { ?>
  14. <li><?php comment_author_link(); ?> <br /> <?php comment_excerpt(); ?> </li>
  15. <?php } ?>
  16. <?php } ?>
  17. </ul>
  18. <?php } else { ?> <!-- if there was no comment in that post,yet -->
  19. <span class="comment">No comment so far</span>
  20. <?php } ?>
  21. </div>
  22.  
  23. <!-- end recent comment-->

Report this snippet  

You need to login to post a comment.