Using WordPress ‘login_title’ PHP filter

The login_title WordPress PHP Filter allows you to modify the title tag content for the login page.

Usage

add_filter('login_title', 'your_function_name', 10, 2);
function your_function_name($login_title, $title) {
  // your custom code here
  return $login_title;
}

Parameters

  • $login_title (string): The page title, with extra context added.
  • $title (string): The original page title.

More information

See WordPress Developer Resources: login_title

Examples

Customize the login page title

Customize the login page title to display “My Custom Login” instead of the default title.

add_filter('login_title', 'custom_login_title', 10, 2);
function custom_login_title($login_title, $title) {
  $login_title = 'My Custom Login';
  return $login_title;
}

Append the site name to the login page title

Append the site name to the login page title.

add_filter('login_title', 'append_site_name_to_login_title', 10, 2);
function append_site_name_to_login_title($login_title, $title) {
  $site_name = get_bloginfo('name');
  $login_title .= ' - ' . $site_name;
  return $login_title;
}

Remove extra context from the login page title

Remove extra context from the login page title, displaying only the original title.

add_filter('login_title', 'remove_context_from_login_title', 10, 2);
function remove_context_from_login_title($login_title, $title) {
  return $title;
}

Display a custom login page title for a specific user role

Display a custom login page title for users with the ‘editor’ role.

add_filter('login_title', 'editor_login_title', 10, 2);
function editor_login_title($login_title, $title) {
  if (current_user_can('editor')) {
    $login_title = 'Editor Login';
  }
  return $login_title;
}

Localize the login page title

Localize the login page title based on the user’s language.

add_filter('login_title', 'localize_login_title', 10, 2);
function localize_login_title($login_title, $title) {
  $current_language = get_user_locale();
  if ($current_language == 'fr_FR') {
    $login_title = 'Connexion';
  } elseif ($current_language == 'es_ES') {
    $login_title = 'Iniciar sesión';
  }
  return $login_title;
}