WordPress.org

Ready to get started?Download WordPress

Codex

Plugin API/Action Reference/after switch theme

This page is marked as incomplete. You can help Codex by expanding it.

Description

Runs when the blog's theme is changed. Action function argument: name of the new theme. If used in a theme, it only works if the theme that adds action is the one being enabled. Can be used to run certain code when enabling a theme.

Usage

<?php

add_action("after_switch_theme", "textdomain_redirectToThemeOptions");

function textdomain_redirectToThemeOptions(){
  $redirectTo = admin_url().'themes.php?page=textdomain-theme-options';
  wp_redirect($redirectTo);
}

add_action('admin_menu', 'textdomain_themeOptionsMenu');

function textdomain_themeOptionsMenu(){
  add_theme_page('Theme Options', 'Theme Options', 'edit_theme_options', 'textdomain-theme-options', 'textdomain_themeOptions');
}

function textdomain_themeOptions(){
  // Your Theme Options Page Here
}

?>


Related