W3cubDocs

/WordPress

do_action( ‘after_switch_theme’, string $old_name, WP_Theme $old_theme )

Fires on the next WP load after the theme has been switched.

Description

The parameters differ according to whether the old theme exists or not.
If the old theme is missing, the old name will instead be the slug of the old theme.

See ‘switch_theme’.

Parameters

$old_namestring
Old theme name.
$old_themeWP_Theme
WP_Theme instance of the old theme.

More Information

Callback functions attached to this hook are only triggered in the theme (and/or child theme) being activated. To do things when your theme is deactivated, use switch_theme.

Source

do_action( 'after_switch_theme', $old_theme->get( 'Name' ), $old_theme );

Changelog

Version Description
3.3.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/hooks/after_switch_theme