Filter hook 'comments_number'

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

View Source

comments_number

Filter Hook
Description
Filters the comments count for display.

Hook Information

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

Hook Parameters

Type Name Description
string $comments_number_text A translatable string formatted based on whether the count is equal to 0, 1, or 1+.
int $comments_number The number of post comments.

Usage Examples

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

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

Source Code Context

wp-includes/comment-template.php:1016 - How this hook is used in WordPress core
<?php
1011  	 *
1012  	 * @param string $comments_number_text A translatable string formatted based on whether the count
1013  	 *                                     is equal to 0, 1, or 1+.
1014  	 * @param int    $comments_number      The number of post comments.
1015  	 */
1016  	return apply_filters( 'comments_number', $comments_number_text, $comments_number );
1017  }
1018  
1019  /**
1020   * Retrieves the text of the current comment.
1021   *

PHP Documentation

<?php
/**
	 * Filters the comments count for display.
	 *
	 * @since 1.5.0
	 *
	 * @see _n()
	 *
	 * @param string $comments_number_text A translatable string formatted based on whether the count
	 *                                     is equal to 0, 1, or 1+.
	 * @param int    $comments_number      The number of post comments.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/comment-template.php
Related Hooks

Related hooks will be displayed here in future updates.