I know that plugins can deactivate itself, but how about themes?

I work on a parent theme (Framework) and I don't want users to be able to activate it.

This is what I have so far. The problem is that there is a message coming up from wordpress that the theme is demaged when I do this this way. It shows the last theme there one time but then swiches again to the default theme because wordpress expect the theme I clicked activate for. I need to bypass this somehow. I want to show my own message instead. Any ideas?

Although I don't know if its right to set all to one value, isn't template supposed to be the parent themes name when there is one? Or does WP figure this out automatically?

add_action( 'after_switch_theme', 'switch_to_last_theme' );

function switch_to_last_theme( $old_theme ){

    echo "<br><br><h1>just for testing last theme: $old_theme</h1>";

    update_option('template', $old_theme);
    update_option('stylesheet', $old_theme);
    update_option('current_theme', $old_theme);


1 Answer 1


There's the check_theme_switched() function.

Checks if a theme has been changed and runs ‘after_switch_theme’ hook on the next WP load

Note: The action has one argument, named $old_theme that you can access. After running the filter, the option theme_switched gets set to true.

  • well I am still not sure what to do with it exactly to get to my goal.
    – amy
    May 8, 2012 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.