Skip to content

Instantly share code, notes, and snippets.

@davewardle
Created November 1, 2019 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davewardle/282688d938b457c90f166e764d216b6f to your computer and use it in GitHub Desktop.
Save davewardle/282688d938b457c90f166e764d216b6f to your computer and use it in GitHub Desktop.
Hack to load a different theme based on URL
<?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