Title: Numbering Comments
Last modified: August 18, 2016

---

# Numbering Comments

 *  Resolved [Doodlebee](https://wordpress.org/support/users/doodlebee/)
 * (@doodlebee)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/numbering-comments-1/)
 * So, I’ve taken a different stance with my comments lists on my new theme, but
   I’m having just a *teensy* issue here. What I’m doing is chucking the `<ul><li
   >` stuff for listing comments people have placed. I’m doing a more stylistic 
   version instead, where the actual comment number is set as a kind of background
   to the comment instead.
 * You can see it in action [here](http://www.candybill.com/?p=14): scroll to the
   bottom and you can see the two comments, and how the background has the numbers
   in it.
 * Now, the thing is, if you notice in that post that the numbers are actually “
   3” and “4” – not “1” and “2”. If you look through other posts it’s the same –
   it appears that it’s taking the actual comment ID and putting that in the background–
   so it’s showing the comment ID for the whole *site*, not just for the post at
   hand.
 * Of course, I look back at my code and smack myself in the head, because that’s
   what I *told* it to do. Duh. My code looks like this:
 *     ```
       <?php foreach ($comments as $comment) : ?>
   
       <div class="comment<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
       <div class="number"><?php echo comment_ID(); ?></div>
       ```
   
 * Now, the “number” div is what holds the actual number you see in the background.
   I’m using the “comment_ID” – which is why it’s showing the numbering system the
   way it is. Is there a way to change that so it shows the correct numbers for 
   each *post* – not for the site on the whole?
 * Hopefully that makes sense!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [19 years, 1 month ago](https://wordpress.org/support/topic/numbering-comments-1/#post-545804)
 * Neat look, BTW. I don’t like the pink (I’m more of a purple fan, personally),
   but the number in the background like that is damn cool.
 * Anyway, here’s your fixed code:
 *     ```
       <?php
       $my_comment_count = 1;
       foreach ($comments as $comment) : ?>
       <div class="comment<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
       <div class="number"><?php echo $my_comment_count; $my_comment_count++; ?></div>
       ```
   
 *  Thread Starter [Doodlebee](https://wordpress.org/support/users/doodlebee/)
 * (@doodlebee)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/numbering-comments-1/#post-545805)
 * Thank you Otto! Works like a charm. (And no, I’m not a “pink” person either –
   but sometimes certain shades will hit me right. It’s rare though – I’m more of
   a “green” girl!)
 * Thanks again 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Numbering Comments’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Doodlebee](https://wordpress.org/support/users/doodlebee/)
 * Last activity: [19 years, 1 month ago](https://wordpress.org/support/topic/numbering-comments-1/#post-545805)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
