Skip to content

Instantly share code, notes, and snippets.

@devuri
Forked from dbernar1/switch-theme.php
Created November 18, 2016 17:21
Show Gist options
  • Save devuri/94e93503a9a3ada25e87ee2ac7133a85 to your computer and use it in GitHub Desktop.
Save devuri/94e93503a9a3ada25e87ee2ac7133a85 to your computer and use it in GitHub Desktop.
Switch theme based on whether the user is logged in or not. One theme for guests, other theme for logged in users.
<?php
/**
* Plugin name: Different theme for guest than logged in user
*/
// You can also put this file in mu-plugins dir.
add_filter( 'template', 'switch_theme__db' );
add_filter( 'stylesheet', 'switch_theme__db' );
function switch_theme__db( $template ) {
if ( ! is_admin() ) {
if ( is_user_logged_in() ) {
return 'twentythirteen';
} else {
return $template;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment