Filter hook 'get_comments_number'

in WP Core File wp-includes/comment-template.php at line 933

View Source

get_comments_number

Filter Hook
Description
Filters the returned comment count for a post.

Hook Information

File Location wp-includes/comment-template.php View on GitHub
Hook Type Filter
Line Number 933

Hook Parameters

Type Name Description
string|int $comments_number A string representing the number of comments a post has, otherwise 0.
int $post_id Post ID.

Usage Examples

Basic Usage
<?php
// Hook into get_comments_number
add_filter('get_comments_number', 'my_custom_filter', 10, 2);

function my_custom_filter($comments_number, $post_id) {
    // Your custom filtering logic here
    return $comments_number;
}

Source Code Context

wp-includes/comment-template.php:933 - How this hook is used in WordPress core
<?php
 928  	 * @since 1.5.0
 929  	 *
 930  	 * @param string|int $comments_number A string representing the number of comments a post has, otherwise 0.
 931  	 * @param int        $post_id Post ID.
 932  	 */
 933  	return apply_filters( 'get_comments_number', $comments_number, $post_id );
 934  }
 935  
 936  /**
 937   * Displays the language string for the number of comments the current post has.
 938   *

PHP Documentation

<?php
/**
	 * Filters the returned comment count for a post.
	 *
	 * @since 1.5.0
	 *
	 * @param string|int $comments_number A string representing the number of comments a post has, otherwise 0.
	 * @param int        $post_id Post ID.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/comment-template.php
Related Hooks

Related hooks will be displayed here in future updates.