I am building my website on Wordpress and I have created my custom login page.But for a post when an user comments and other nonlogged see the comment with along with a line down "Login to reply".And when the user clicks on that"Login" from "Login to reply" it redirects to wp-login.php.So how to redirect users to custom login page when "login to reply" for a post is clicked on wordpress instead of wp-login.php.
I am building my website on Wordpress and I have created my custom login page.But for a post when an user comments and other nonlogged see the comment with along with a line down "Login to reply".And when the user clicks on that"Login" from "Login to reply" it redirects to wp-login.php.So how to redirect users to custom login page when "login to reply" for a post is clicked on wordpress instead of wp-login.php.
Try using this in your functions.php
file or in a plugin file-
add_filter( 'login_url', 'wpse_290288_custom_login_url', 10, 3 );
function wpse_290288_custom_login_url( $login_url, $redirect, $force_reauth ) {
$login_page_id = 123; // ID of your custom login page
return get_permalink( $login_page_id );
}