Reputation: 387
I am working on a wordpress plugin which allows user to enter name of four themes using four text boxes. Then based on some condition, at one point one theme out of the 4 gets activated.Then after some time based on some condition other theme gets activated.
if(condition_one) {
Activate Theme1
}
else if(Condition_Two)
{
Activate Theme2
}
etc.
I tried using the below method.
update_option('current_theme','ThemeName');
update_option('template','ThemeName');
update_option('stylesheet','ThemeName');
The themes are actually getting changed but is this the correct way to do it. Am i considering all the fields in the wp_options table. Is there a way using which by just passing the theme name all the relevant fields get updated.
Any Help would be greatly appreciated.
Thanks
Upvotes: 0
Views: 220
Reputation: 1404
The correct way is to use the switch_theme
function: http://codex.wordpress.org/Function_Reference/switch_theme
Upvotes: 2