Change “Lost Your Password?” Text In WordPress

Quick Summary
- A gettext filter replaces the Lost your password link text with wording such as Forgot your password, without editing core or plugin files.
- The match is exact, including capitals and the question mark, and applies wherever that string prints, including wp-login.php and WooCommerce's My Account form.
- The filter receives already translated text, so compare against the translated wording on non-English sites and keep the check fast.
WordPress and many plugins show a “Lost your password?” link with their login forms. To change the wording without editing core or plugin files, you can filter the text while it is being translated. The gettext filter runs for every translatable string, and this function swaps just the one you want.
Add the code to your child theme’s functions.php file.
function change_lost_your_password ($text) {
if ($text == 'Lost your password?'){
$text = 'Forgot your password?';
}
return $text;
}
add_filter( 'gettext', 'change_lost_your_password' );How it works
- The function compares each string with
'Lost your password?'. When it matches, it returns'Forgot your password?'; every other string passes through unchanged. - Change either text to suit your site. The match is exact, including capital letters and the question mark.
- It applies wherever that exact string is printed, for example the
wp-login.phpscreen and the WooCommerce My Account login form. - The value the filter receives is the already translated text. If your site isn’t in English, compare against the translated wording instead.
- Because
gettextruns so often, keep the function to a quick comparison like this one.
Related articles
- changing the Post Comment button label: another core label, changed with its own filter
- skipping the WooCommerce log out confirmation: another small fix for account screens
See also: Email-Only Login and Strong Passwords in WordPress and WooCommerce.
