update_term_cache( WP_Term[] $terms, string $taxonomy =  )

In this article

Updates terms in cache.

Parameters

$termsWP_Term[]required
Array of term objects to change.
$taxonomystringoptional
Not used.

Default:''

Source

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

Changelog

VersionDescription
2.3.0Introduced.

User Contributed Notes

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