comments_number( string|false $zero = false, string|false $one = false, string|false $more = false, int|WP_Post $post )
Displays the language string for the number of comments the current post has.
Parameters
Source
File: wp-includes/comment-template.php
.
View all references
function comments_number( $zero = false, $one = false, $more = false, $post = 0 ) {
echo get_comments_number_text( $zero, $one, $more, $post );
}
Changelog
Version | Description |
---|---|
5.4.0 | The $deprecated parameter was changed to $post . |
0.71 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Text Response to Number of Comments
Displays text based upon number of comments: Comment count zero – no responses; comment count one – one response; more than one comment (total 42) displays 42 responses.
Title For Comments Section
You might want to have a title above your comments section that includes the number of comments. This example shows how to do that and have all the strings also be translatable.
Usage of ‘comments_number’ filter
Top ↑
Feedback
The use of
_n()
can simplify the above function definition to one line:— By crstauf —