Title: Comments Count in 2.7
Last modified: August 19, 2016

---

# Comments Count in 2.7

 *  [madpostman](https://wordpress.org/support/users/madpostman/)
 * (@madpostman)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/comments-count-in-27/)
 * Hey Everyone, 2.7 is pretty sweet so far, just ran into a small problem.
 * I’ve used this handy guide to get better control over styling my comments. [http://clarktech.no-ip.com/wordpress/wordpress-27-comment-callback-function](http://clarktech.no-ip.com/wordpress/wordpress-27-comment-callback-function)
 * I want to implement a comment count (1, 2, 3, 4, etc) for each new comment that
   will be displayed next to it. I’ve used these functions that have worked for 
   me before:
 * Before the loop
    `<?php $cmntCnt = 1; ?>`
 * Within the loop
    `<?php echo($cmntCnt++); ?>`
 * Now that my comment styling is in a function, they don’t seem to work anymore.
   They only output “1” for each comment.
 * Any ideas?
    Hope that made sense.

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

 *  [Jauhari](https://wordpress.org/support/users/jauhari/)
 * (@jauhari)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/comments-count-in-27/#post-924077)
 * Anybody can solve this problem? I need this too
 * thanks
 *  Moderator [Jan Dembowski](https://wordpress.org/support/users/jdembowski/)
 * (@jdembowski)
 * Forum Moderator and Brute Squad
 * [17 years, 5 months ago](https://wordpress.org/support/topic/comments-count-in-27/#post-924078)
 * This worked for me (PHP programmers please comment, my PHP fu can be lacking).
 * In your function.php define $cmntCnt as global
 *     ```
       <?php
       function custom_comment($comment, $args, $depth) {
              $GLOBALS['comment'] = $comment; ?>
              <?php global $cmntCnt; ?>
       ```
   
 * Then output the $cmntCnt in the function where/how you want it
 * `<?php echo $cmntCnt+1; ?>`
 * And at the bottom before the end of the function, increment the comment count
 *     ```
       <?php $cmntCnt = $cmntCnt + 1; ?>
       <?php } ?>
       ```
   
 * See if that works for you. I’m still playing with the styling of mine, but this
   validates on my blog and PHP is not tossing errors.
 * Happy New Year.
 *  [Jauhari](https://wordpress.org/support/users/jauhari/)
 * (@jauhari)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/comments-count-in-27/#post-924156)
 * Thanks you it’s work now
 *  [quiltro](https://wordpress.org/support/users/quiltro/)
 * (@quiltro)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/comments-count-in-27/#post-924161)
 * It’s work for me also. Thanks for Sharing
 *  [etomyam](https://wordpress.org/support/users/etomyam/)
 * (@etomyam)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/comments-count-in-27/#post-924259)
 * After hours of seraching, finally I’ve found this solution, thanks alot

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

The topic ‘Comments Count in 2.7’ is closed to new replies.

## Tags

 * [Comments](https://wordpress.org/support/topic-tag/comments/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [number](https://wordpress.org/support/topic-tag/number/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 5 participants
 * Last reply from: [etomyam](https://wordpress.org/support/users/etomyam/)
 * Last activity: [16 years, 9 months ago](https://wordpress.org/support/topic/comments-count-in-27/#post-924259)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
