On this page
clean_object_term_cache( int|array $object_ids, array|string $object_type )
Removes the taxonomy relationship to terms from the cache.
Description
Will remove the entire taxonomy relationship containing term $object_id. The term IDs have to exist within the taxonomy $object_type for the deletion to take place.
See also
- get_object_taxonomies() : for more on $object_type.
Parameters
$object_idsint|array Required-
Single or list of term object ID(s).
$object_typearray|string Required-
The taxonomy object type.
Source
File: wp-includes/taxonomy.php. View all references
function clean_object_term_cache( $object_ids, $object_type ) {
global $_wp_suspend_cache_invalidation;
if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
return;
}
if ( ! is_array( $object_ids ) ) {
$object_ids = array( $object_ids );
}
$taxonomies = get_object_taxonomies( $object_type );
foreach ( $taxonomies as $taxonomy ) {
wp_cache_delete_multiple( $object_ids, "{$taxonomy}_relationships" );
}
wp_cache_delete( 'last_changed', 'terms' );
/**
* Fires after the object term cache has been cleaned.
*
* @since 2.5.0
*
* @param array $object_ids An array of object IDs.
* @param string $object_type Object type.
*/
do_action( 'clean_object_term_cache', $object_ids, $object_type );
}
Hooks
- do_action( 'clean_object_term_cache',
array $object_ids ,string $object_type ) -
Fires after the object term cache has been cleaned.
Related
Uses
| Uses | Description |
|---|---|
| wp_cache_delete_multiple() wp-includes/cache.php | Deletes multiple values from the cache in one call. |
| wp_cache_delete() wp-includes/cache.php | Removes the cache contents matching key and group. |
| get_object_taxonomies() wp-includes/taxonomy.php | Returns the names or objects of the taxonomies which are registered for the requested object or object type, such as a post object or post type name. |
| do_action() wp-includes/plugin.php | Calls the callback functions that have been added to an action hook. |
Used By
| Used By | Description |
|---|---|
| wp_delete_term() wp-includes/taxonomy.php | Removes a term from the database. |
| clean_post_cache() wp-includes/post.php | Will clean the post in the cache. |
| clean_attachment_cache() wp-includes/post.php | Will clean the attachment in the cache. |
| clean_bookmark_cache() wp-includes/bookmark.php | Deletes the bookmark cache. |
Changelog
| Version | Description |
|---|---|
| 2.3.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/clean_object_term_cache