Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.