Title: wp_clean_themes_cache
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_clean_themes_cache( bool $clear_update_cache = true )

## In this article

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

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

Clears the cache held by [get_theme_roots()](https://developer.wordpress.org/reference/functions/get_theme_roots/)
and [WP_Theme](https://developer.wordpress.org/reference/classes/wp_theme/).

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

 `$clear_update_cache`booloptional

Whether to clear the theme updates cache.

Default:`true`

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

    ```php
    function wp_clean_themes_cache( $clear_update_cache = true ) {
    	if ( $clear_update_cache ) {
    		delete_site_transient( 'update_themes' );
    	}
    	search_theme_directories( true );
    	foreach ( wp_get_themes( array( 'errors' => null ) ) as $theme ) {
    		$theme->cache_delete();
    	}
    }
    ```

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

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

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

Searches all registered theme directories for complete and valid themes.

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

Returns an array of [WP_Theme](https://developer.wordpress.org/reference/classes/wp_theme/) objects based on the arguments.

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

Deletes a site transient.

  |

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

Clears existing update caches for plugins, themes, and core.

  | 
| [WP_Automatic_Updater::run()](https://developer.wordpress.org/reference/classes/wp_automatic_updater/run/)`wp-admin/includes/class-wp-automatic-updater.php` |

Kicks off the background update process, looping through all pending updates.

  | 
| [Theme_Upgrader::current_after()](https://developer.wordpress.org/reference/classes/theme_upgrader/current_after/)`wp-admin/includes/class-theme-upgrader.php` |

Turns off maintenance mode after upgrading the active theme.

  | 
| [Theme_Upgrader::install()](https://developer.wordpress.org/reference/classes/theme_upgrader/install/)`wp-admin/includes/class-theme-upgrader.php` |

Install a theme package.

  | 
| [Theme_Upgrader::upgrade()](https://developer.wordpress.org/reference/classes/theme_upgrader/upgrade/)`wp-admin/includes/class-theme-upgrader.php` |

Upgrades a theme.

  | 
| [Theme_Upgrader::bulk_upgrade()](https://developer.wordpress.org/reference/classes/theme_upgrader/bulk_upgrade/)`wp-admin/includes/class-theme-upgrader.php` |

Upgrades several themes at once.

  |

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

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

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

## User Contributed Notes

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