do_action( 'switch_theme', string $new_name , WP_Theme $new_theme , WP_Theme $old_theme )
Fires after the theme is switched.
Contents
Description
See ‘after_switch_theme’.
Parameters
More Information
switch_theme is triggered when the blog’s theme is changed. Specifically, it fires after the theme has been switched but before the next request. Theme developers should use this hook to do things when their theme is deactivated.
Theme functions attached to this hook are only triggered in the theme being deactivated. To do things when your theme is activated, use after_switch_theme.
Functions attached to this action hook receive one parameter: a string with the name of the new theme being activated.
Source
File: wp-includes/theme.php
.
View all references
do_action( 'switch_theme', $new_name, $new_theme, $old_theme );
Changelog
Version | Description |
---|---|
4.5.0 | Introduced the $old_theme parameter. |
1.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
This hook is useful while deactivating a theme.
For example:
Delete a theme’s options after deactivation