Reputation: 197
I have a wordpress website that host several themes inside it. Now I want to switch the themes for visitor base on the URL that they enter. for example :
my WP website is at http://www.myblog.com/wp/
but if user enter :
http://www.myblog.com/wp?theme=twentyten -> using twentyten theme
and if user enter :
http://www.myblog.com/wp?theme=mycustomtheme ->using mycustometheme
then is there any plugins available out there? I've been searching for days but no one seam to work for me.
Any suggestion is very appreciated!
Thanks
Upvotes: 0
Views: 5747
Reputation: 322
for who is still interested you have a WordPress functions that switches the theme
switch_theme( $stylesheet )
see https://codex.wordpress.org/Function_Reference/switch_theme
Just be care to call it in the right time, I would write it in a mu-plugin for use it.
Upvotes: 0
Reputation: 1185
I've found this good tutorial about base theme swithing on URL.
First, you have to catch the parameter in the URL:
function sjc_add_query_vars($vars)
{
return array('template') + $vars;
}
add_filter('query_vars', 'sjc_add_query_vars');
And then you serve the template:
function sjc_template($template)
{
global $wp;
if ($wp->query_vars['template']=='basic')
{
return dirname( __FILE__ ) . '/single-basic.php';
}
else
{
return $template;
}
}
add_filter('single_template', 'sjc_template');
Please note that the code above check if $wp->query_vars['template']=='basic'
and not simply return the template specified in the URL, because it could be a security issue.
Upvotes: 0
Reputation: 4480
This might help: http://codex.wordpress.org/Theme_Switching
There are 2 plugins noted in that url: http://wordpress.org/extend/plugins/theme-preview/ Theme preview which is what you want.
http://wordpress.org/extend/plugins/theme-switcher/ Theme switcher which do that too and create a sidebar widget so user can change the template.
Upvotes: 0
Reputation: 1454
I haven't done it, and looking for a minute I don't see a plugin that does that for you. I think your best bet is to make a plugin that would change the theme variable based on the base URL. It's about as simple of a plugin as you can make, so it would be a good one to cut your teeth on if you have any programming ability whatsoever.
Upvotes: 1