Hi,
I like to display comments on index page rather then on post page. Hence, I have search wordpress and found this solution:
<div>
<?php
$comment_array = array_reverse(get_approved_comments($wp_query->post->ID));
$count = 1;
?>
<?php if ($comment_array) { ?>
<span> <?php comments_number(‘No comment’,’1 comment’,'% comments’); ?></span> – Latest by:
<ul>
<?php foreach($comment_array as $comment){ ?>
<?php if ($count++ <= 2) { ?>
<li><?php comment_author_link(); ?> <br /> <?php comment_excerpt(); ?> </li>
<?php } ?>
<?php } ?>
</ul>
<?php } else { ?>
<span>No comment so far</span>
<?php } ?>
</div>
Need to add this code inside loop of index.php and should be after <?php the_content(); ?>.
Thanks,
Shane G.
Popularity: 1%