get_comments_number

Definition:
function get_comments_number( $post_id = 0 ) {}

Retrieve the amount of comments a post has.

Parameters

  • int $post_id: The Post ID

Return values

returns:The number of comments a post has

Defined filters

  • get_comments_number
    apply_filters('get_comments_number', $count, $post_id)

Source code

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);

}

1284

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: