I'd like to simplify the installation and default settings of my theme, by creating a plugin that installs it (versus the traditional "Appearance > Install Themes" routine. Once installed, I want to be able to delete the plugin from the site, so there will be no dependencies on it after activation.

Is this possible?

I would include the theme.zip file inside the plugin.zip file so that it could easily be transferred up and over to the themes directory.

If possible, any examples of this would be helpful. Thanks in advance for your help.

  • 5
    205 questions and 9 answers. That's a mighty imbalance.
    – anu
    Apr 12, 2011 at 13:45

2 Answers 2


Why not set the default settings from within the theme? You can use the 'swith_theme' action.

To answer your question: yes, it's possible, but it requires that the user's setup allows moving files, which can lead to more headaches than covenience.

  • @scribu: Thanks, I was anticipating that response. In this case, I have a fallback for moving issues, This is my preferred install, then I have a fallback ready as in try/catch.
    – Scott B
    Mar 13, 2011 at 5:48
  • @scribu: The main reason I want the plugin install is that it allows me to have a base theme package, then via individual plugins (each tuned with presets for different types of sites), I can create customized versions of the theme with one click, vs multiple configuration steps that are required in theme options.
    – Scott B
    Mar 13, 2011 at 5:51
  • Unless those plugins provide some additional functionality, that still doesn't make much sense. Just have a welcome page in the theme, where you ask the user to choose the site's profile.
    – scribu
    Mar 13, 2011 at 9:10
  • Or make child themes.
    – scribu
    Mar 13, 2011 at 9:10
  • @scribu: where would you store your settings for the various site profiles? That might be something I'd consider, depending on complexity to the user. This is all about bulletproofing the setup for the end user. Give them any more than a 3 or 4 options and its like you are asking them to commit to marriage.
    – Scott B
    Mar 13, 2011 at 9:31

Yes it is: https://wordpress.stackexchange.com/a/302650/29133

 * For directory structure like:
 * /your-plugin/
 * - /your-plugin.php
 * - /themes/
 * - - /yourthemename/

Add to the your-plugin.php file:

function updateTheme($theme){
    update_option('template', $theme);
    update_option('stylesheet', $theme);
    update_option('current_theme', $theme);

add_action( 'setup_theme', 'change_theme' );

function change_theme(){

 //Replace with your own conditional
 $enable_theme = true; // Forcing true;

  if($enable_theme == true):
    register_theme_directory( plugin_dir_path( __FILE__ ) . 'themes' );
    $theme = "yourthemename";
    $theme = "default";


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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