Skip to content

Instantly share code, notes, and snippets.

@wpjess
Created December 10, 2020 05:40
Show Gist options
  • Save wpjess/18c25942e9cac9f79839fb8568691df4 to your computer and use it in GitHub Desktop.
Save wpjess/18c25942e9cac9f79839fb8568691df4 to your computer and use it in GitHub Desktop.
Hide a WordPress site unless logged in
function hide_from_everyone() {
if( !is_admin() && !is_user_logged_in() ){
die();
}
}
add_action( 'template_redirect', 'hide_from_everyone' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment