How to Modify the “Lost your password?” Text in WordPress Login the Easy Way

Last Updated on January 11, 2024 by Mike Kipruto

To modify or change the “Lost your Password” text in the WordPress Login Screen, please add the following code to your theme’s functions.php file or in a custom plugin:

/**
 * How to Modify the "Lost your password?" link HTML in WordPress login.
 *
 * @link https://kipmyk.co.ke/code/how-to-modify-the-lost-your-password-text-in-wordpress-login-the-easy-way/
 * @param string $html_link The original HTML link for lost password.
 * @return string Modified HTML link for lost password.
 */
function mk_custom_lost_password_html_link( $html_link ) {
    // You can replace the link text below with your desired custom link text.
    $custom_link_text = __( 'Your Custom Text Here?', 'text-domain' );
    
    // Modify the link text in the HTML link.
    $html_link = preg_replace( '/>(.*?)<\/a>/', '>' . $custom_link_text, $html_link );
    
    return $html_link;
}
add_filter( 'lost_password_html_link', 'mk_custom_lost_password_html_link' );

This code hooks into, the WordPress lost_password_html_link filter hook.