Adding Numbers to WordPress Comments

It might be useful if we can add numbering to a wordpress comment so that we may be able to count of how many comments we obtained. Not to only us but also to the visitors who left their comments. Here is how we can add numbers to wordpress comments.

You may need to tweak your theme to enable this feature. We assume that you already know what files are inside your theme. You will need an html/php editor like dreamweaver or notepad++ for editing.

  1. First thing you need to do is locate the comments.php file and open it with the editor.
  2. Then you will see arrays of php codes. Locate the code that starts the comment loop. It will look like below:
    <?php if ( $comments ) : ?>
  3. Then place the following code above the code in step 2.
    <?php $i = 0; ?>
  4. After that locate the code that looks like this:
    <?php foreach ($comments as $comment) : ?>
  5. Place the following code below the code in step 4.
    <?php $i++; ?>
  6. Finally, place this code where you want it to display the comment numbers, and click Save:
    <span>
    <?php echo $i; ?>
    </span>
  7. For customization, locate stylesheet (style.css) and place this code:
    .count {
    float:right;
    padding: 10px;
    font-size:18px;
    color:#000000;
    }

Anything left? Adjust the stylesheet property for better appearance and suitable placement according to your need if you want more. That’s it!

Share & Save!

  • Share/Bookmark

Subscribe! (free)

Related Posts:


More Reading Materials

Be the first to comment.

Leave Comment