wp_update_comment_count

Definition:
function wp_update_comment_count($post_id, $do_deferred=false) {}

Updates the comment count for post(s).
When $do_deferred is false (is by default) and the comments have been set to be deferred, the post_id will be added to a queue, which will be updated at a later date and only updated once per post ID.

Parameters

  • int $post_id: Post ID
  • bool $do_deferred: Whether to process previously deferred post comment counts

Return values

returns:True on success, false on failure

Source code

function wp_update_comment_count($post_id, $do_deferred=false) {

	static $_deferred = array();



	if ( $do_deferred ) {

		$_deferred = array_unique($_deferred);

		foreach ( $_deferred as $i => $_post_id ) {

			wp_update_comment_count_now($_post_id);

			unset( $_deferred[$i] ); /** @todo Move this outside of the foreach and reset $_deferred to an array instead */

		}

	}



	if ( wp_defer_comment_counting() ) {

		$_deferred[] = $post_id;

		return true;

	}

	elseif ( $post_id ) {

		return wp_update_comment_count_now($post_id);

	}



}

4217

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: