Support » Fixing WordPress » How to display last comments (without using the widget)?

  • Here is the code I found on a blog:

    <div class="post-recent-comment">
    <?php
     $comment_array = array_reverse(get_approved_comments($wp_query->post->ID));
     $count = 1;
    ?>
    <?php if ($comment_array) { ?>
    
    <span class="comment"><?php comments_number('No comment','1 comment','% comments'); ?></span> – Latest by:
      <ul class="commentlist">
     <?php foreach($comment_array as $comment){ ?>
      <?php if ($count++ <= 2) { ?>
       <li>&lt?php comment_author_link(); ?><br /><?php comment_excerpt(); ?></li>
      <?php } ?>
     <?php } ?>
      </ul>
    <?php } else { ?>
     <span class="comment">No comments so far</span>
    <?php } ?>
    </div>

    I put it on my homepage but it does not seam to function well as it always display “No comments so far” while I have already made and approved a couple of them.

    Can someone help me here ?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to display last comments (without using the widget)?’ is closed to new replies.