Title: Reverse comment numbering
Last modified: August 19, 2016

---

# Reverse comment numbering

 *  [Hegarty](https://wordpress.org/support/users/hegarty/)
 * (@hegarty)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/reverse-comment-numbering/)
 * Hello,
 * in order to give every comment a number, my functions.php contains the following
   code:
 *     ```
       <?php global $comment_num;
       if(isset($comment_num)) {
       $comment_num++;
       } else { $comment_num = 1; }
       ?>
       ```
   
 * How am I able to modify this code in order to reverse the numbering? The very
   last comment at the bottom of the page should become “Comment no.1”.
 * Thanks in advance for your help!

Viewing 1 replies (of 1 total)

 *  Thread Starter [Hegarty](https://wordpress.org/support/users/hegarty/)
 * (@hegarty)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/reverse-comment-numbering/#post-1899957)
 * Got the solution:
 *     ```
       <?php global $comment_num;
       if(isset($comment_num)) {
       $comment_num--;
       } else { global $post; $comment_num = $post->comment_count; }
       ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Reverse comment numbering’ is closed to new replies.

## Tags

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

 * 1 reply
 * 1 participant
 * Last reply from: [Hegarty](https://wordpress.org/support/users/hegarty/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/reverse-comment-numbering/#post-1899957)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
