The clean_taxonomy_cache WordPress action fires after a taxonomy’s caches have been cleaned.
Usage
add_action('clean_taxonomy_cache', 'your_custom_function', 10, 1); function your_custom_function($taxonomy) { // your custom code here }
Parameters
$taxonomy
(string) – The taxonomy slug.
More information
See WordPress Developer Resources: clean_taxonomy_cache
Examples
Log taxonomy cache cleaning
Log when a taxonomy cache is cleaned.
add_action('clean_taxonomy_cache', 'log_taxonomy_cache_cleaning', 10, 1); function log_taxonomy_cache_cleaning($taxonomy) { error_log("Taxonomy cache cleaned for: {$taxonomy}"); }
Update custom cache
Update your custom cache after a taxonomy’s cache is cleaned.
add_action('clean_taxonomy_cache', 'update_custom_cache', 10, 1); function update_custom_cache($taxonomy) { // Update your custom cache for the specific taxonomy }
Notify admin
Send a notification to the admin when a taxonomy cache is cleaned.
add_action('clean_taxonomy_cache', 'notify_admin_taxonomy_cache_cleaned', 10, 1); function notify_admin_taxonomy_cache_cleaned($taxonomy) { $admin_email = get_option('admin_email'); $subject = 'Taxonomy Cache Cleaned'; $message = "The cache for the '{$taxonomy}' taxonomy has been cleaned."; wp_mail($admin_email, $subject, $message); }
Refresh related content
Refresh related content when a taxonomy cache is cleaned.
add_action('clean_taxonomy_cache', 'refresh_related_content', 10, 1); function refresh_related_content($taxonomy) { // Refresh content related to the specific taxonomy }
Trigger custom action
Trigger a custom action after a taxonomy cache is cleaned.
add_action('clean_taxonomy_cache', 'trigger_custom_action', 10, 1); function trigger_custom_action($taxonomy) { // Trigger your custom action for the specific taxonomy }