WordPress: How do I customize "Lost your password" text on login page?
Solution 1
Change wordpress text "Lost your password?"
function change_lost_your_password ($text) {
if ($text == 'Lost your password?'){
$text = 'Forgot Password?';
}
return $text;
}
add_filter( 'gettext', 'change_lost_your_password' );
Solution 2
To change this text or any text for that matter you can use the following function, it's almost the same Super Model's answer but documented and code standards validated.
/**
* Change some text.
*
* @param String $text WordPress Text Stream.
* @return String
*/
function acme_change_some_text( $text ) {
if ( 'Lost your password?' === $text ) {
$text = 'Forgot Your Password?';
}
// Important to return the text stream.
return $text;
}
// Hook this function up.
add_action( 'gettext','acme_change_some_text' );
Here's a handy gif to explain what's happening.
Solution 3
The function has several parameters to change the default settings. For instance, you can specify: the ID names of the form and its elements (for CSS styling), whether to print the "Remember Me" checkbox, and the URL a user is redirected to after a successful login (default is to stay on the same Page):
<?php
if ( ! is_user_logged_in() ) { // Display WordPress login form:
$args = array(
'redirect' => admin_url(),
'form_id' => 'loginform-custom',
'label_username' => __( 'Username custom text' ),
'label_password' => __( 'Password custom text' ),
'label_remember' => __( 'Remember Me custom text' ),
'label_log_in' => __( 'Log In custom text' ), //you can change here
'remember' => true
);
wp_login_form( $args );
} else { // If logged in:
wp_loginout( home_url() ); // Display "Log Out" link.
echo " | ";
wp_register('', ''); // Display "Site Admin" link.
}
?>
The form itself is generated by code in the WordPress wp-includes/general-template.php
file. Because your custom login Page is different than the built-in WordPress login page (wp-login.php)
jasonTakesManhattan
Updated on June 24, 2022Comments
-
jasonTakesManhattan almost 2 years
I realize this is probably simple, but I can't figure out how to change the "Lost your password" text on the WordPress login page.
On the login page, there is a link that says, "Lost your password," and I want to change that text to read something like, "Get a new password." I'm just not sure what function to use to overwrite that text in the child theme.
-
Billu over 2 yearsAvoid changing into the core files.