Retrieve the amount of comments a post has.

Signature

get_comments_number( $post_id = 0 )
post_id
 (int) The Post ID
Default: 0

Return

(int) The number of comments a post has

Source

function get_comments_number( $post_id = 0 ) {
	$post_id = absint( $post_id );

	if ( !$post_id )
		$post_id = get_the_ID();

	$post = get_post($post_id);
	if ( ! isset($post->comment_count) )
		$count = 0;
	else
		$count = $post->comment_count;

	return apply_filters('get_comments_number', $count, $post_id);
}
WP Trac GitHub Bitbucket

Link here