I have copied wp-login.php code in a template file in my theme
Created a new page and assigned the template /login
Added the following code in function.php
// Hook the appropriate WordPress action
add_action('init', 'prevent_wp_login');
function prevent_wp_login()
{
// WP tracks the current page - global the variable to access it
global $pagenow;
// Check if a $_GET['action'] is set, and if so, load it into $action variable
$action = (isset($_GET['action'])) ? $_GET['action'] : '';
// Check if we're on the login page, and ensure the action is not 'logout'
if ($pagenow == 'wp-login.php' && (!$action || ($action && !in_array($action, array('logout', 'lostpassword', 'rp', 'resetpass'))))) {
// Load the custom login page url
$page = '/login';
// Redirect to the custom login page
wp_redirect($page);
// Stop execution to prevent the page loading for any reason
exit();
}
}
the page keeps directing me to the login after pressing the login button
2
Answers
I have found I solution from https://agconsulting.altervista.org/all-you-need-to-know-about-wp-customize-login-page-without-plugin/
the code in the function.php file is:
that’s not the home page thats login page… change page to…
`$page = get_site_url();`