Copy and paste this code into your functions.php file to dynamically redirect users who are not logged in to the default wp-login.php page when they try to visit any page on your site. Once they log it, they will be redirected back to the page they tried to access.
// function that will redirect users to the wp-login.php page if they are not logged in function md_redirect() { // Current Page global $pagenow; // Check to see if user in not logged in and not on the login page if(!is_user_logged_in() && $pagenow != 'wp-login.php') // If user is, Redirect to Login form. auth_redirect(); } // adds your function to the WordPress build add_action( 'wp', 'md_redirect' );