update_term_cache() WordPress Function

The update_term_cache() function is used to update the cache for a given term. This function will grab all relevant data for the term from the database and update the cache. This function is typically used when a term is created, edited, or deleted.

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

Updates terms in cache.


Parameters

$terms

(WP_Term[])(Required)Array of term objects to change.

$taxonomy

(string)(Optional)Not used.

Default value: ''


Top ↑

Source

File: wp-includes/taxonomy.php

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


Top ↑

Changelog

Changelog
VersionDescription
2.3.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