clean_taxonomy_cache() WordPress Function

The clean_taxonomy_cache() function is a utility function that is used to clear the cached data for a given taxonomy. This function is typically used when you need to update the cached data for a taxonomy after making changes to the terms in that taxonomy.

clean_taxonomy_cache( string $taxonomy ) #

Cleans the caches for a taxonomy.


Parameters

$taxonomy

(string)(Required)Taxonomy slug.


Top ↑

Source

File: wp-includes/taxonomy.php

function clean_taxonomy_cache( $taxonomy ) {
	wp_cache_delete( 'all_ids', $taxonomy );
	wp_cache_delete( 'get', $taxonomy );
	wp_cache_delete( 'last_changed', 'terms' );

	// Regenerate cached hierarchy.
	delete_option( "{$taxonomy}_children" );
	_get_term_hierarchy( $taxonomy );

	/**
	 * Fires after a taxonomy's caches have been cleaned.
	 *
	 * @since 4.9.0
	 *
	 * @param string $taxonomy Taxonomy slug.
	 */
	do_action( 'clean_taxonomy_cache', $taxonomy );
}


Top ↑

Changelog

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