WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp update comment count

Contents

Description

Updates the comment count for post(s).

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

If the comments have not be set up to be deferred, then the post will be updated. When $do_deferred is set to true, then all previous deferred post IDs will be updated along with the current $post_id.

Usage

<?php wp_update_comment_count$post_id$do_deferred ?>

Parameters

$post_id
(integer) (required) Post ID
Default: None
$do_deferred
(boolean) (optional) Whether to process previously deferred post comment counts
Default: false

Return Values

(boolean) 
True on success, false on failure

Examples

Notes

Change Log

Since: 2.1.0

Source File

wp_update_comment_count() is located in wp-includes/comment.php.

Related

 

See also index of Function Reference and index of Template Tags.