Steps
-
Add the PHP code to your child theme’s
functions.phpfile or the Code Snippets plugin. -
Save and activate the snippet.
-
Visit the WordPress login page and test with invalid login credentials.
Hook Used
– login_errors — Filters the error message displayed on the WordPress login screen.
Type: WordPress Login Customization
Output: WordPress displays your custom error message instead of its default login error details.
Why use this snippet? It provides consistent login feedback and avoids revealing whether a username or password was incorrect.
Customize: Replace the message inside the quotes with your preferred text.
function custom_login_error_message() {
return 'Login failed. Please check your username and password and try again.';
}
add_filter( 'login_errors', 'custom_login_error_message' );
Tested on
Reported by the author on October 23, 2026. WPFolks has not verified this.
Not tested against WordPress 7.1.4. It may still work.
