Created
November 1, 2019 15:49
-
-
Save davewardle/282688d938b457c90f166e764d216b6f to your computer and use it in GitHub Desktop.
Hack to load a different theme based on URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'template', 'switch_to_new_theme' ); | |
add_filter( 'stylesheet', 'switch_to_new_theme' ); | |
function switch_to_new_theme( $template ) { | |
$request = $GLOBALS['_SERVER']['REQUEST_URI']; | |
if ( | |
strpos( $request, '/url1' ) === 0 || | |
strpos( $request, '/url2' ) === 0 || | |
strpos( $request, '/url3' ) === 0 || | |
strpos( $request, '/url4' ) === 0 | |
) { | |
return 'name_of_new_theme'; | |
} | |
return $template; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment