after_switch_theme WordPress Action Hook

The after_switch_theme hook is triggered when a user switches themes. This hook can be used to perform any actions that need to happen after a theme is switched. For example, you could use this hook to run a function that updates the theme's options in the database.

do_action( 'after_switch_theme', string $old_name, WP_Theme $old_theme ) #

Fires on the first WP load after a theme switch if the old theme still exists.


Description

This action fires multiple times and the parameters differs according to the context, if the old theme exists or not. If the old theme is missing, the parameter will be the slug of the old theme.


Top ↑

Parameters

$old_name

(string)Old theme name.

$old_theme

(WP_Theme)WP_Theme instance of the old theme.


Top ↑

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.


Top ↑

Source

File: wp-includes/theme.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
3.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More