get_comments_number
Filters the returned comment count for a post.
Usage
add_filter( 'get_comments_number', 'wp_kama_get_comments_number_filter', 10, 2 ); /** * Function for `get_comments_number` filter-hook. * * @param string|int $comments_number A string representing the number of comments a post has, otherwise 0. * @param int $post_id Post ID. * * @return string|int */ function wp_kama_get_comments_number_filter( $comments_number, $post_id ){ // filter... return $comments_number; }
- $comments_number(string|int)
- A string representing the number of comments a post has, otherwise 0.
- $post_id(int)
- Post ID.
Changelog
Since 1.5.0 | Introduced. |
Where the hook is called
get_comments_number
wp-includes/comment-template.php 933
return apply_filters( 'get_comments_number', $comments_number, $post_id );