Security question – Display a General Custom Login Error Message

Add the following to your functions.php file.

function my_custom_error_messages() {
    global $errors;
    $err_codes = $errors->get_error_codes();

    // Invalid username.
    if ( in_array( 'invalid_username', $err_codes ) ) {
        $error="<strong>ERROR</strong>: Custom Message Here";
    }

    // Incorrect password.
    if ( in_array( 'incorrect_password', $err_codes ) ) {
        $error="<strong>ERROR</strong>: Another Custom Message Here";
    }

    return $error;
}

add_filter( 'login_errors', 'my_custom_error_messages');

You can write a separate error message for each or combine the if statements if you only want one message. Like this.

if ( in_array( 'invalid_username', $err_codes ) || in_array( 'incorrect_password', $err_codes ) ) {
    $error="<strong>ERROR</strong>: Custom Message Here";
}