One of the things that has been worrying me for long the link to the individual comments in WordPress. The default structure of a link to a comment is :
http://POST-PERMALINK/#comment-COMMENT-ID
This is what it remains like on most of the WordPress blogs. It wouldn’t look bad if you just has a few hundred blogs. But, the latest comment on the latest post (as of now) on Problogger.net has the ID 4452651.
So, I just wanted to change this thing. I wanted to has #comment-1 for the first comment and #comment-7 for the 7th comment and so on. I searched the web for a hack or a plugin, but in vain. (Let me know if one is available). So, I just figured out my own method, which I’m going to teach you. I made it as a hack for a theme, rather than a plugin because it needs you to edit your theme templates. But, as per the principles, you need not touch WordPress’s core files.
Step 1 : Adding the 1, 2, 3 Increment
Open your comments.php file and search for the following :
<?php foreach ($comments as $comment) : ?>
And, change it to as follows :
<?php $i = 1; foreach ($comments as $comment) : ?>
Now, search for the immediate next occurrence of this :
<?php endforeach; /* end for each comment */ ?>
And, change it to this :
<?php $i++; endforeach; /* end for each comment */ ?>






