Using WordPress ‘login_headertext’ PHP filter

login_headertext is a WordPress PHP filter that allows you to modify the text of the header logo link above the login form.

Usage

add_filter('login_headertext', 'custom_login_headertext');
function custom_login_headertext($login_header_text) {
    // your custom code here
    return $login_header_text;
}

Parameters

  • $login_header_text (string) – The login header logo link text.

More information

See WordPress Developer Resources: login_headertext

Examples

Change header text to “My Custom Site”

Change the login header text to “My Custom Site”:

add_filter('login_headertext', 'change_login_header_text');
function change_login_header_text($login_header_text) {
    $login_header_text = 'My Custom Site';
    return $login_header_text;
}

Display site name as login header text

Display your site’s name as the login header text:

add_filter('login_headertext', 'use_site_name_as_login_header_text');
function use_site_name_as_login_header_text($login_header_text) {
    $login_header_text = get_bloginfo('name');
    return $login_header_text;
}

Add a custom prefix to the login header text

Add a custom prefix, like “Welcome to,” before the site name:

add_filter('login_headertext', 'add_custom_prefix_to_login_header_text');
function add_custom_prefix_to_login_header_text($login_header_text) {
    $login_header_text = 'Welcome to ' . get_bloginfo('name');
    return $login_header_text;
}

Add the current year to the login header text

Display the current year along with the site name:

add_filter('login_headertext', 'add_current_year_to_login_header_text');
function add_current_year_to_login_header_text($login_header_text) {
    $current_year = date('Y');
    $login_header_text = get_bloginfo('name') . ' - ' . $current_year;
    return $login_header_text;
}

Translate login header text

Translate the login header text using a translation function like __(), assuming the text domain is “my-text-domain”:

add_filter('login_headertext', 'translate_login_header_text');
function translate_login_header_text($login_header_text) {
    $login_header_text = __('Welcome to My Website', 'my-text-domain');
    return $login_header_text;
}