Title: Show post Comment Thread count
Last modified: August 31, 2016

---

# Show post Comment Thread count

 *  [JonathanLaba](https://wordpress.org/support/users/jonathanlaba/)
 * (@jonathanlaba)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/show-post-comment-thread-count/)
 * Hi,
    I’m currently using this function to display comments but I’d like to **
   only count the comment threads** and not include the nested elements.
 * <?php comments_number(‘(No Comments)’, ‘(One Comment)’, ‘(% Comments)’ );?>
 * I was took a look at this thread numbering plugin but I think that’s only for
   numbering like bullets.
    [https://en-ca.wordpress.org/plugins/gregs-threaded-comment-numbering/](https://en-ca.wordpress.org/plugins/gregs-threaded-comment-numbering/)
 * Any Help would be greatly appreciated

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

 *  [Juhi Saxena](https://wordpress.org/support/users/juhise/)
 * (@juhise)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/show-post-comment-thread-count/#post-6980549)
 * Hey JonathanLaba,
 *  I’ll do whatever I can to help.Please try to use this code:
 *     ```
       <?php
               // type = comment will only get "real" comments, no ping-/trackbacks
       $comments = get_comments(array('type' => 'comment','post_id' => get_the_ID()));
   
       $count=0;
       foreach($comments as $comment) {
          // if the comment has no parent, it´s the first of a thread
          if( empty( $comment->comment_parent ) ) { $count++; }
       }  
   
       switch($count) {
          case 0: echo "NO COMMENT"; break;
          case 1: echo "ONE COMMENT"; break;
          default: echo "$count COMMENTS"; break;
       }
   
       ?>
       ```
   
 * I hope it will solve your problem.
 * Good Luck
    Juhi
 *  Moderator [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * (@zoonini)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/show-post-comment-thread-count/#post-6980563)
 * If you’re using a premade theme – as opposed to a custom one you’ve made yourself–
   just a heads-up that the best way to make changes to a theme is to use a child
   theme, so your tweaks won’t be overwritten when updating the theme. Here are 
   some guides in case you haven’t made one before:
 * [http://codex.wordpress.org/Child_Themes](http://codex.wordpress.org/Child_Themes)
   
   [http://op111.net/53/](http://op111.net/53/) [http://vimeo.com/39023468](http://vimeo.com/39023468)
   [https://www.smashingmagazine.com/2016/01/create-customize-wordpress-child-theme/](https://www.smashingmagazine.com/2016/01/create-customize-wordpress-child-theme/)

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

The topic ‘Show post Comment Thread count’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/show-post-comment-thread-count/#post-6980563)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
