wp_defer_comment_counting( bool $defer = null )

Whether to defer comment counting.


Description 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 Parameters

$defer

(bool) (Optional)

Default value: null


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: wp-includes/comment.php

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

Top ↑

Changelog Changelog

Changelog
Version Description
2.5.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.