Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've managed to get my "semi noob proof" site installer plugin 98% complete, but I'm having a slight issue with the theme activation. The plugin is able to copy the theme into the themes directory fine. However, my switch_theme statement that attempts to set it to the active theme is missing something.

I'm using...

function activate_theme(){
switch_theme('my_theme', 'style.css');
}

...as a trigger statement inside the plugin to activate the newly uploaded theme (its uploaded as part of a function that processes further up in the code from the "activate_theme()" function. My theme, in this instance is called 'my_theme' and that's what I'm using in the theme's style.css

I can tell that the switch theme is partially working, since when I click on "Appearance", the default 2010 theme is no longer the active theme, however, the "my_theme" theme is not set to active either. Its as if the process only partially completed and neither 2010 nor my theme are fully activated. So, I still have to manually click "Activate" to finish the process.

What could I be missing?

share|improve this question
    
since switch_theme() is located in wp-includes/theme.php, maybe you can debug it (by debugger, or by echoing) –  Lea Cohen Mar 27 '11 at 9:39

1 Answer 1

up vote 2 down vote accepted

I think, you must also set the options template and stylesheet, thats all. I use this via filter to set a theme for testing or on a category, post-type and so on. But you must change the fields in table options for active the theme ready.

I hope this help, i dont tested - only my idea.

share|improve this answer
    
You are spot on. I actually figured this out and forgot to update the question. So I'm upvoting and selecting your answer. Thanks. –  Scott B Mar 30 '11 at 4:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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