Number your wordpress comments

February 3, 2009 · Print This Article

Do your blog posts receive lots of comments? If yes, it can be really useful for both you and your readers to number it. Here’s how to do it easily and efficiently.

Open comments.php and find the following line:

<?php foreach ($comments as $comment) : ?>

Just below this line, initialize a counter variable:

<?php $i = 0; ?>

Just after this line, increment the counter:

<?php $i++; ?>

Now, you just have to echo the $i variable to get the number of the current comment. Paste this code anywhere on your comments loop:

<?php echo $i; ?>

Your comments are now numbered.


Your choice for site templates and wordpress themes

Comments

Got something to say?

You must be logged in to post a comment.