wp_defer_term_counting() WordPress Function

The wp_defer_term_counting() function allows you to defer the updating of term count information in the database. This can be useful when you need to update a large number of terms and don't want the overhead of updating the counts for each term. The function takes two parameters: The first parameter is the term_id of the term you want to update. The second parameter is the number of terms you want to update. The function will return an array of the deferred term_ids.

wp_defer_term_counting( bool $defer = null ) #

Enables or disables term counting.


Parameters

$defer

(bool)(Optional) Enable if true, disable if false.

Default value: null


Top ↑

Return

(bool) Whether term counting is enabled or disabled.


Top ↑

Source

File: wp-includes/taxonomy.php

function wp_defer_term_counting( $defer = null ) {
	static $_defer = false;

	if ( is_bool( $defer ) ) {
		$_defer = $defer;
		// Flush any deferred counts.
		if ( ! $defer ) {
			wp_update_term_count( null, null, true );
		}
	}

	return $_defer;
}


Top ↑

Changelog

Changelog
VersionDescription
2.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More