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 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.


Parameters Parameters

$old_name

(string) Old theme name.

$old_theme

(WP_Theme) WP_Theme instance of the old theme.


Top ↑

Source Source

File: wp-includes/theme.php

View on Trac


Top ↑

Changelog Changelog

Changelog
Version Description
3.3.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by NateWr

    Update the default medium image size when a theme is activated.

    function example_update_default_image_size( $old_theme_name, $old_theme = false ) {
    	update_option( 'medium_size_w', 800 );
    	update_option( 'medium_size_h', 400 );
    }
    add_action( 'after_switch_theme', 'example_update_default_image_size', 10, 2 );
    

You must log in before being able to contribute a note or feedback.