Filter pre_option_stylesheet
. Sample code, not tested:
add_filter( 'pre_option_stylesheet', 'wpse_100854_switch_stylesheet' );
function wpse_100854_switch_stylesheet( $false )
{
if ( empty ( $_GET['theme'] )
return $false;
$themes = wp_get_themes( array( 'allowed' => true ) );
if ( isset ( $themes[ $_GET['theme'] ] ) )
return $_GET['theme'];
return $false;
}
The URL should look like example.com/?theme=theme_directory_slug
.
To change just the template for a specific page, hook into template_include
:
add_filter( 'template_include', 'wpse_100854_switch_template' );
function wpse_100854_switch_template( $template )
{
if ( empty ( $_GET['template'] )
return $false;
// do not allow to break out of the directory
$new = ltrim( $_GET['template'], '.' );
$path = get_template_directory() . "/templates/$new.php";
if ( file_exists( $path ) )
return $path;
return $template;
}
Now add a directory templates
to your theme. When someone requests example.com/?template=blue
and the template blue.php
exists in the special directory, it will be used.