update_term_cache()WP 2.3.0

Updates terms in cache.

No Hooks.

Return

null. Nothing (null).

Usage

update_term_cache( $terms, $taxonomy );
$terms(WP_Term[]) (required)
Array of term objects to change.
$taxonomy(string)
Not used.
Default: ''

Changelog

Since 2.3.0 Introduced.

update_term_cache() code WP 6.4.3

function update_term_cache( $terms, $taxonomy = '' ) {
	$data = array();
	foreach ( (array) $terms as $term ) {
		// Create a copy in case the array was passed by reference.
		$_term = clone $term;

		// Object ID should not be cached.
		unset( $_term->object_id );

		$data[ $term->term_id ] = $_term;
	}
	wp_cache_add_multiple( $data, 'terms' );
}