0

For wp-login.php, the default page title, as displayed in the browser tab, is "Log In".

I need to change this value using a filter in functions.php.

Every solution I've read addresses the header title but I need to modify the head title.

1

I don't see a filter in wp-login for the title, but it does use __() so you might be able to use the gettext filter like:

add_filter('gettext', 'wpse_214367_change_login_title', 20, 3);

function wpse_214367_change_login_title( $translated_text, $untranslated_text, $domain ) {

     if( "Log In" == $untranslated_text  )
            $translated_text = "My New Title";

   return $translated_text;
}

EDIT: Please try this and let me know if it works. May also need to add a check to make sure you are on wp-login.php page

 add_filter('gettext', 'wpse_214367_change_login_title', 20, 3);

function wpse_214367_change_login_title( $translated_text, $untranslated_text, $domain ) {
    static $count=0;
     if( "Log In" == $untranslated_text AND $count === 0 ){
            $translated_text = "My New Title";
            $count++;
      }
   return $translated_text;
}
  • This works. Greatly appreciated. – Clarus Dignus Jan 12 '16 at 18:49
  • This also changes the text of the submit button. Is there any way to prevent this? – Clarus Dignus Jan 13 '16 at 16:20
  • Your edit works. I was originally playing with this: wordpress.stackexchange.com/a/18656/41545 but couldn't integrate into your code. It might be worth checking out since it only activates the filter right before the login form is printed. It seems to create an action to achieve this. Can this action be integrated into your solution? In contrast, here's an example of the "wrong" way by filtering all core strings (i.e. places other than wp-login): wordpress.stackexchange.com/a/82845/41545. – Clarus Dignus Jan 13 '16 at 22:57
  • ...or will this equally do the trick: wordpress.stackexchange.com/a/12865/41545 for checking that the page wp-login? – Clarus Dignus Jan 13 '16 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.