On this page
wp_defer_comment_counting( bool $defer = null ): bool
Determines whether to defer comment counting.
Description
When setting $defer to true, all post comment counts will not be updated until $defer is set to false. When $defer is set to false, then all previously deferred updated post comment counts will then be automatically updated without having to call wp_update_comment_count() after.
Parameters
$deferbool Optional-
Default:
null
Return
bool
Source
File: wp-includes/comment.php. View all references
function wp_defer_comment_counting( $defer = null ) {
static $_defer = false;
if ( is_bool( $defer ) ) {
$_defer = $defer;
// Flush any deferred counts.
if ( ! $defer ) {
wp_update_comment_count( null, true );
}
}
return $_defer;
}
Related
Uses
| Uses | Description |
|---|---|
| wp_update_comment_count() wp-includes/comment.php | Updates the comment count for post(s). |
Used By
| Used By | Description |
|---|---|
| wp_delete_attachment() wp-includes/post.php | Trashes or deletes an attachment. |
| wp_delete_post() wp-includes/post.php | Trashes or deletes a post or page. |
| wp_update_comment_count() wp-includes/comment.php | Updates the comment count for post(s). |
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_defer_comment_counting