I want to hide the front-end from every visitor/logged out user. To see the front-end, every user must have been registered and logged in.

Any visitor that's logged out should be redirected to the default WordPress login page.

1 Answer 1


One way of doing this would be to add the code below to the top of your template file(s):

<?php // redirect to login page if user is not logged in 
if ( !is_user_logged_in() ) :
    header('Location: /wp-login.php');

There are some subtleties around redirecting in PHP that you may want to consider, but for me the above code works.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.