WPDev.one
Core Function
View Source on Trac ↗

get_comments_number()

get_comments_number( mixed $post = 0 )

Retrieves the amount of comments a post has.

Parameters 1 required

Name / Type Description
(int

| WP_Post) $post Optional. Post ID or WP_Post object. Default is the global `$post`.

Required

Return Value

((string)
(string | int) If the post exists, a numeric string representing the number of comments the post has, otherwise 0.

Function Information

Since Version
1.5.0
Source File
wp-includes/comment-template.php
Advertisement