Skip to content

Instantly share code, notes, and snippets.

@dbernar1
Created August 7, 2014 16:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dbernar1/6cff3f251f6c5985fd86 to your computer and use it in GitHub Desktop.
Save dbernar1/6cff3f251f6c5985fd86 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