HTTP/2 302
server: nginx
date: Sat, 27 Dec 2025 12:57:17 GMT
content-type: text/html; charset=UTF-8
x-olaf: ⛄
vary: accept, content-type
expires: Wed, 11 Jan 1984 05:00:00 GMT
cache-control: no-cache, must-revalidate, max-age=0, no-store, private
x-redirect-by: WordPress
location: https://developer.wordpress.org/reference/hooks/after_switch_theme/
x-frame-options: SAMEORIGIN
alt-svc: h3=":443"; ma=86400
x-nc: MISS ord 1
HTTP/2 200
server: nginx
date: Sat, 27 Dec 2025 12:57:18 GMT
content-type: text/html; charset=UTF-8
vary: Accept-Encoding
x-olaf: ⛄
vary: accept, content-type
link:
; rel="https://api.w.org/"
link:
; rel="alternate"; title="JSON"; type="application/json"
link: ; rel=shortlink
x-frame-options: SAMEORIGIN
content-encoding: gzip
alt-svc: h3=":443"; ma=86400
x-nc: MISS ord 1
after_switch_theme – Hook | Developer.WordPress.org
do_action ( ‘after_switch_theme’, string $old_name , WP_Theme $old_theme )
Fires on the next WP load after the theme has been switched.
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’ .
$old_namestring Old theme name.
$old_themeWP_Theme
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 .
Version Description 3.3.0 Introduced.
Example migrated from Codex:
Add options for your theme and set them to their default values.
Update the default medium image size when a theme is activated.