How to Add Numbers to Your Comments in WordPress
by c.bavota on | Posted in Tutorials | 18 comments
I have been receiving a large amount of comments on my Magazine Basic theme and I was having a bit of trouble referencing certain ones, so I decided to add some numbers to the side of each comments to make it easier. It was actually a simple thing to do so here is a quick tutorial. I use the classic theme that comes pre-installed on WordPress for the example.
Open comments.php and find this the lines that look similar to this:
<ol id="commentlist">
<?php foreach ($comments as $comment) : ?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
<?php echo get_avatar( $comment, 32 ); ?>
<?php comment_text() ?>
<p><cite><?php comment_type(_c('Comment|noun'), __('Trackback'), __('Pingback')); ?> <?php _e('by'); ?> <?php comment_author_link() ?> — <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite> <?php edit_comment_link(__("Edit This"), ' |'); ?></p>
</li>
<?php endforeach; ?>
</ol>
Now all you need to do is change it to this:
<ol id="commentlist">
<?php $i = 1; ?>
<?php foreach ($comments as $comment) : ?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
<?php echo get_avatar( $comment, 32 ); ?>
<?php comment_text() ?>
<p><cite><?php comment_type(_c('Comment|noun'), __('Trackback'), __('Pingback')); ?> <?php _e('by'); ?> <?php comment_author_link() ?> — <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite> <?php edit_comment_link(__("Edit This"), ' |'); ?></p>
<div class="commentnumber"><?php echo $i; ?></div>
</li>
<?php $i++; ?>
<?php endforeach; ?>
After that, open up your style.css and add something like this:
.commentnumber {
position: absolute;
right: 5px;
top: 5px;
font-size: 18px;
color: #efefef;
}
.commentlist li {
position: relative;
}
And that should do it.

Two issues please, but first: thank you vey much for Magazine Basic theme. Is is a fantastic theme).
The issues:
1-I am using Magazine Basic theme . The comments does not show its number.
at comments.php (at Magazine Basica theme ) I could not find this any similar lines as you show above.
2-at any comment, there is no “reply” written, instead there is a gray botton ( that became red on roll over ).
How can I solve these two issues?
Thanks in advance.
Hey Jack,
1. I am adding comment numbers to the next version of the theme. Should be done shortly.
2. You need to turn on nested comments in your admin. Go to Settings => Discussion and check the appropriate box. That should turn on the reply button.
c.bavota,
1-Ok, I will wait for the new version.
2-I nested comments. Now it is perfect.
Once again, thanks a lot, you theme is very good.
Hey, c. bavota:
I have put some ads from AdSense at the side bar 2 ( right ). It is perfect.
I would like to put some ads from Adsense at the begin or at the end of each post. What do you suggest?
A plugin or what? And if it is a plugin, what plugin?
I am sorry to bother you, but there are hundreds of plugins for add AdSense.
Thanks
Hi,
Does anybody known a good “plugin” to add Ads from Adsense to Magazine Basic theme?
I want to put some AdSense at my posts.
Thanks in advance
Hey Jack,
There are a lot of adsense plugins and I am not too sure which is the best. There is an article at http://www.quickonlinetips.com/archives/2006/11/10-best-wordpress-plugins-for-google-adsense/ that might help you out.
NOTE: This only works for numbering comments on WordPress version 2.6.x. Check out my post “How to Add Nested Comments to Your WordPress Theme” to see how to add numbers to comments in WordPress 2.7.
Hey, c. bavota:
I have put some ads from AdSense at the side bar 2 ( right ). It is perfect.
I would like to put some ads from Adsense at the begin or at the end of each post. What do you suggest?
A plugin or what? And if it is a plugin, what plugin?
I am sorry to bother you, but there are hundreds of plugins for add AdSense.
Thankshttp://www.surucu-kurslari.com
thank you
thank you admin
Thank you so much!! Although I forget to print the i at the first time. That is really helpful for my long comment list! I was seeking this plug-in only for a week. That is easy to just put i inside of comment.php!
Thanks again!
Hey, c. bavota:
Do you know How to Add Numbers to my posts in WordPress ?
My wordpress theme is a list of post and Y want to display for each post the number.
1. post1
2. post2
……..
etc
Hi, Thanks for the Magazine Theme. Did you add the comment count to the latest version of the theme that WP 3.0 compatible? I don’t see an option anywhere.
Not yet. Hopefully in the next version.
Thank you, this post has saved me a bundle of work!
Hi bavota.
Help me with twenty ten theme.
Thanks!
You should probably post questions about TwentyTen on the WordPress forum.