Title: wp_count_comments
Published: April 25, 2014
Last modified: February 24, 2026

---

# apply_filters( ‘wp_count_comments’, array|stdClass $count, int $post_id )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/wp_count_comments/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/wp_count_comments/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/wp_count_comments/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/wp_count_comments/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/hooks/wp_count_comments/?output_format=md#wp--skip-link--target)

Filters the comments count for a given post or the whole site.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/wp_count_comments/?output_format=md#parameters)󠁿

 `$count`array|stdClass

An empty array or an object containing comment counts.

`$post_id`int

The post ID. Can be 0 to represent the whole site.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/wp_count_comments/?output_format=md#source)󠁿

    ```php
    $filtered = apply_filters( 'wp_count_comments', array(), $post_id );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/comment.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/comment.php#L1468)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/comment.php#L1468-L1468)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/wp_count_comments/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_count_comments()](https://developer.wordpress.org/reference/functions/wp_count_comments/)`wp-includes/comment.php` |

Retrieves the total comment counts for the whole site or a single post.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/wp_count_comments/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.7.0](https://developer.wordpress.org/reference/since/2.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_count_comments%2F)
before being able to contribute a note or feedback.