How To Add Comments Number Support In WordPress Theme

Posted by

Hi,

When we adds comment number support to the wordpress theme which makes easily to identify total number of comments. These are the steps which needs to be perform in order to ddd Comment Number Support To your wordpress theme:

1) Backup your comments.php file of your theme.
2) Open comments.php file of your theme to edit it.
3) Find this loop code in comment loop:

<?php if ( $comments ) : ?>

4) Add this code immediately above the code mentioned in step 3:
<?php $i = 0; ?>

5) Now, find this code:
<?php foreach ($comments as $comment) : ?>

6) Add this below the code mentioned in step 5:
<?php $i++; ?>

7) Now, you need to add this code where you want to display comment number:

<span>
<?php echo $i; ?>
</span>

8) Save the comments.php file.

9) Now, add this stylesheet in style.css of your theme:
.count {
float:right;
padding: 10px;
font-size:18px;
color:#000000;
}

You can adjust the stylesheet according to your requirement.

That’s it!

Thanks,

Shane G.