Restrict wordpress access to logged users only
This works only for blog pages, pages, and single posts. You need to disable redirection on the login page. Here you can find how to detect the login page. Check if wp-login is current page So to redirect globally as you want use: if(!is_user_logged_in() && !is_wplogin() ) wp_safe_redirect( wp_login_url() ); Function is_wplogin() is from here: … Read more