Reputation: 9167
I have an idea for running multiple wordpress themes at ounce. This might be a good thing to build into a wordpress plugin, if possible. And yes, I might undertake such a task if it isn't ridiculously hard.
(Also, if you are interested in teaming up with me, let me know (leave a comment), I am decent at javascript and php, but not to great, and would love some help!)
This is how I see it working: Current "set" theme is accessible here: "www.foo.com/" Second theme accessible here: "www.foo.com/index.php?set_theme=theme2&" Third theme accessible here: "www.foo.com/index.php?set_theme=THEME_NAME_HERE&" etc...
This could be used for javascript fall backs. For example, if you go to www.foo.com/?page_id=9 and have javascript turned on, you will hit a javascript redirect to "www.foo.com/index.php?set_theme=THEM_WITH_JAVASCRIPT&page_id=9".
This is how I imagine the plugin code looking/working:
if(isset($_GET['set_theme'])){
$loadme = cleaned($_GET['set_theme']);
if($loadme exists){
loadtheme($loadme);
} else {
//go on as usual, as if this plugin doesnt exist
}
} else {
//go on as usual, as if this plugin doesnt exist
}
And of course, all the links would have to ad ?set_theme=FOOBAR&
So, my main questions are:
Upvotes: 3
Views: 651
Reputation: 9167
Found a plugin that was 98% of the way there. Wordpress Theme Switcher Reloaded.
Just changed the ts_get_theme() function as follows:
function ts_get_theme() {
if (!empty($_GET["wptheme"])) {
return $_GET["wptheme"];
} else {
return '';
}
}
Upvotes: 0
Reputation: 30823
Don't really need a plugin, just add this to functions.php:
function theme_switcher() {
if(isset($_GET['theme']) $theme = $_GET['theme'];
global $wpdb;
if (isset($theme)) {
$wpdb->prefix
$queries = “UPDATE “.$wpdb->prefix.”options SET option_value = ‘”.$theme.”‘ WHERE option_name = ‘template’ OR option_name = ‘stylesheet’ OR option_name = ‘current_theme’;”;
$wpdb->query($query);
}
}
add_action('wp_head','switchTheme')
then use mywebsite.com/?theme=myNewTheme
to switch them
Disclaimer: untested!!
Upvotes: 0
Reputation: 301135
You might like to look at the Theme Switcher plugin to see how that accomplishes this task - should give you some ideas.
Upvotes: 1