Title: clean_taxonomy_cache
Published: November 20, 2017
Last modified: February 24, 2026

---

# clean_taxonomy_cache( string $taxonomy )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/clean_taxonomy_cache/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/clean_taxonomy_cache/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/clean_taxonomy_cache/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/clean_taxonomy_cache/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/clean_taxonomy_cache/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/clean_taxonomy_cache/?output_format=md#wp--skip-link--target)

Cleans the caches for a taxonomy.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/clean_taxonomy_cache/?output_format=md#parameters)󠁿

 `$taxonomy`stringrequired

Taxonomy slug.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/clean_taxonomy_cache/?output_format=md#source)󠁿

    ```php
    function clean_taxonomy_cache( $taxonomy ) {
    	wp_cache_delete( 'all_ids', $taxonomy );
    	wp_cache_delete( 'get', $taxonomy );
    	wp_cache_set_terms_last_changed();

    	// Regenerate cached hierarchy.
    	if ( is_taxonomy_hierarchical( $taxonomy ) ) {
    		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 );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/taxonomy.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/taxonomy.php#L3729)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/taxonomy.php#L3729-L3748)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/clean_taxonomy_cache/?output_format=md#hooks)󠁿

 [do_action( ‘clean_taxonomy_cache’, string $taxonomy )](https://developer.wordpress.org/reference/hooks/clean_taxonomy_cache/)

Fires after a taxonomy’s caches have been cleaned.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/clean_taxonomy_cache/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_cache_set_terms_last_changed()](https://developer.wordpress.org/reference/functions/wp_cache_set_terms_last_changed/)`wp-includes/taxonomy.php` |

Sets the last changed time for the ‘terms’ cache group.

  | 
| [wp_cache_delete()](https://developer.wordpress.org/reference/functions/wp_cache_delete/)`wp-includes/cache.php` |

Removes the cache contents matching key and group.

  | 
| [_get_term_hierarchy()](https://developer.wordpress.org/reference/functions/_get_term_hierarchy/)`wp-includes/taxonomy.php` |

Retrieves children of taxonomy as term IDs.

  | 
| [is_taxonomy_hierarchical()](https://developer.wordpress.org/reference/functions/is_taxonomy_hierarchical/)`wp-includes/taxonomy.php` |

Determines whether the taxonomy object is hierarchical.

  | 
| [delete_option()](https://developer.wordpress.org/reference/functions/delete_option/)`wp-includes/option.php` |

Removes an option by name. Prevents removal of protected WordPress options.

  | 
| [do_action()](https://developer.wordpress.org/reference/functions/do_action/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to an action hook.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/clean_taxonomy_cache/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/clean_taxonomy_cache/?output_format=md#)

| Used by | Description | 
| [clean_term_cache()](https://developer.wordpress.org/reference/functions/clean_term_cache/)`wp-includes/taxonomy.php` |

Removes all of the term IDs from the cache.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/clean_taxonomy_cache/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.9.0](https://developer.wordpress.org/reference/since/4.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fclean_taxonomy_cache%2F)
before being able to contribute a note or feedback.