How To: Adding Comment Numbers To Your WordPress Theme
June 6, 2008 by Tony | Tag(s): WordPress Code, WordPress Hacks, WordPress How-To
I’ve noticed a lot of themes that don’t come with numbers on the blog’s comments. 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.
- First thing you will want to do is create a backup your comments.php file.
- Locate the comments.php file.
- Locate the code that starts the comment loop. It will look something like this:
<?php if ( $comments ) : ?> - Place this code immediately above the code in Step 3:
<?php $i = 0; ?> - Now locate the code that looks like this:
<?php foreach ($comments as $comment) : ?> - Placed this code immediately below the code in Step 5:
<?php $i++; ?> - Now use this code where you want to display your comment numbers:
<span class="count">
<?php echo $i; ?>
</span> - Click Save.
- Now go to your stylesheet (style.css) and place this code anywhere on the stylesheet (probably best placed in the comments section):
.count {
float:right;
padding: 10px;
font-size:18px;
color:#000000;
}
You can adjust the stylesheet to fit your comment numbers into the placement and appearance that you want them to have.
Related WordPress Posts
- How To: Display A WordPress Tag Cloud On Your Blog (0)
- How To: Using Another Stylesheet For Certain Pages (0)
- WordPress Hack: Creating a Two-Tiered Navigation Menu (0)
- How To: Alternating Your Post Background Colors (0)
- How To: Hiding Your Sub-Categories in WordPress (0)
- How To: Display the Recent Posts of Specific Categories (0)

![Subscribe to [Blog Tutorials]](http://blogtut.com/wp-content/themes/BlogTutorialPro/images/rss.gif)
![[del.icio.us]](http://blogtut.com/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://blogtut.com/wp-content/plugins/bookmarkify/digg.png)
![[Facebook]](http://blogtut.com/wp-content/plugins/bookmarkify/facebook.png)
![[Google]](http://blogtut.com/wp-content/plugins/bookmarkify/google.png)
![[MySpace]](http://blogtut.com/wp-content/plugins/bookmarkify/myspace.png)
![[Newsvine]](http://blogtut.com/wp-content/plugins/bookmarkify/newsvine.png)
![[Reddit]](http://blogtut.com/wp-content/plugins/bookmarkify/reddit.png)
![[Slashdot]](http://blogtut.com/wp-content/plugins/bookmarkify/slashdot.png)
![[StumbleUpon]](http://blogtut.com/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Technorati]](http://blogtut.com/wp-content/plugins/bookmarkify/technorati.png)
![[Windows Live]](http://blogtut.com/wp-content/plugins/bookmarkify/windowslive.png)
![[Yahoo!]](http://blogtut.com/wp-content/plugins/bookmarkify/yahoo.png)
![[Email]](http://blogtut.com/wp-content/plugins/bookmarkify/email.png)






Comments
Feel free to leave a comment...
and oh, if you want a pic to show with your comment, go get a gravatar!