Never attribute to malice that which is adequately explained by stupidity. —Robert J. Hanlon

How to Number Your WordPress Blog’s Comments [Justin]

Posted by Justin under Photoblogging View recent posts with the tag Photoblogging on Technorati 

Matt Mullenweg has a very nice feature on his site wherein each of the comments you read on a post is numbered (for example). Now, all WordPress comments are automatically numbered, but these numbers don’t start at 1 for each post. For example, the first comment on my last post was #7700. So it takes a simple hack to get the comments to be numbered 1, 2, 3 and so forth on a given post.

The WordPress support forums give enough info to figure out how to do this, and supposedly it’s in the codex, but here’s how I did it (see the results on any page with comments).

First, we need to edit your wp-comments.php file (the “Comments Template” in the theme editor). Find this line:

and replace it with this:

Then, find this line:

and add this line right above it:

What we’ve done so far will create the counter. To make it show up, we add something like this below the comment byline code:


The byline has the “comment posted at … by … ” info, and should be pretty easy to spot.

If you want to just copy my comment template in its entirety, I’ve uploaded the source here.

After that, it’s all a matter of styling it the way you want it. I added this to my stylesheet (ripping off Matt for his CSS):
.comment-number {
color: #CCCCCC;
font-family: trebuchet, verdana, arial, sans-serif;
font-style: italic;
font-variant: normal;
font-weight: normal;
font-size: 40px;
line-height: normal;
font-size-adjust: none;
font-stretch: normal;
margin-top: -45px;
float: right;
}

No, not rocket science. Yes, pretty cool. Yes, I offer WordPress hosting and will answer any crazy question you can come up with. Phil asked about this, and, though he’s not a client, I thought it was cool enough a feature to implement. It’s not added to the theme yet, but will be next time I update it.

2 Responses to “How to Number Your WordPress Blog’s Comments”

Leave a Reply

You can track future comments on this post via this RSS feed. You can trackback this post by pinging this URL. Allowed HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Shrink comment box | Expand comment box



Get RC Via Email



Buy the Emersons a Truck

Because theirs was destroyed in an accident and they need one

    Tagegories

    Browse by category:

    Explore by tag:

    Recent Posts

  • Blogroll

  • Archives


    Use the calendar below to find posts by day (mouseover a day on the calendar to see all posts from that day). If you're looking for a specific post, it's much faster to use the search box above.

    September 2005
    S M T W T F S
    « Aug   Oct »
     123
    45678910
    11121314151617
    18192021222324
    252627282930  

      Recent Comments


      Creative Commons License
      We aren't very into all that copyright stuff. Creative Commons licenses are better, so RC is licensed under this one.
      Quote Radical Congruency at will. Inbound links are appreciated, and required for direct quotations.