Adding Comment Numbers To Your WordPress Theme

July 14, 2008 · Print This Article

This might not be such a bad thing if you don’t get very many comments, but if your blog does get comments it is probably a good idea to show off how many comments you get by numbering them.

Here are the steps you can take to easily add numbers to your WordPress theme’s comments section.

  1. First thing you will want to do is create a backup your comments.php file.
  2. Locate the comments.php file.
  3. Locate the code that starts the comment loop. It will look something like this:
    <?php if ( $comments ) : ?>
  4. Place this code immediately above the code in Step 3:
    <?php $i = 0; ?>
  5. Now locate the code that looks like this:
    <?php foreach ($comments as $comment) : ?>
  6. Placed this code immediately below the code in Step 5:
    <?php $i++; ?>
  7. Now use this code where you want to display your comment numbers:
    <span class="count">
    <?php echo $i; ?>
  8. Click Save.
  9. Now go to your stylesheet (style.css) and place this code anywhere on the stylesheet (probably best placed in the comments section):
    .count {
    padding: 10px;

You can adjust the stylesheet to fit your comment numbers into the placement and appearance that you want them to have.

Your choice for site templates and wordpress themes


Got something to say?

You must be logged in to post a comment.