wp_count_comments

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

Retrieve total comments for blog or single post.
The properties of the returned object contain the ‘moderated’, ‘approved’, and spam comments for either the entire blog or single post. Those properties contain the amount of comments that match the status. The ‘total_comments’ property contains the integer of total comments.

Parameters

  • int $post_id: Optional. Post ID.

Return values

returns:stats.

Defined filters

  • wp_count_comments
    apply_filters('wp_count_comments', array()

Source code

function wp_count_comments( $post_id = 0 ) {

	global $wpdb;



	$post_id = (int) $post_id;



	$stats = apply_filters('wp_count_comments', array(), $post_id);

	if ( !empty($stats) )

		return $stats;



	$count = wp_cache_get("comments-{$post_id}", 'counts');

3499

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: