WordPress Quick Tip: Custom wp-login.php Logo & Url without hacks

Hi All,
today we want to share another quick tutorial on how to change the WordPress logo and url to wordpress.org on the wp-login.php page, without having to change any line of the original code. In this way you will be able to retain the changes without losing them with any update of WordPress.

The wp-login.php Login Form

Original Login Form

Custom Login Logo

In order to change the default WordPress logo you have to add some css styling to the wp-login.php head tag. To do this open the functions.php of your theme of choice and add this new function and its hook.

function my_custom_login_logo() {
    echo '<style type="text/css">
        h1 a { background-image:url('.get_bloginfo('template_url').'/images/logo.png) !important; }
    </style>';
}
add_action('login_head', 'my_custom_login_logo');

You have to upload your image (in this case logo.png) in your theme’s images directory. You can further personalize the wp-login.php page adding more css styling in the functions but don’t go too far! Keep it simple, baby.

Note: if you are using a child theme, you cannot use the template_url information keyword, because it will return the parent theme’s directory. Instead you will need to use stylesheet_directory as keyword for .get_bloginfo().

Custom Login Url

With the previous code you have changed the logo but there’s still a problem: clicking on your new logo still direct you to the wordpress.org address. You can change this adding a second function to the functions.php file.

function my_custom_login_url() {
  return site_url();
}
add_filter( 'login_headerurl', 'my_custom_login_url', 10, 4 );

In this case I only added the site_url function that will return the full path of your WordPress blog, but you can customize it with whatever url you want.

Conclusions

With these two simple functions you have the choice to personalize your login form of your WordPress blog without having to change any line of the default code. In this way no further WordPress updates will break your code.

Thanks for your attention and we hope you’ll find this helpful.

L

  • Pingback: Tweets that mention Wordpress Quick Tip: Custom wp-login.php Logo & Url without hacks | PrimeGap -- Topsy.com()

  • http://graffitikings.blogthisbiz.com/ Laurence

    Nice publish, I really wait for posts from you.

  • Drew

    Very nice. However, I found that when I used the second code, ‘custom login url’, I added a link to a url within the site directory – what I mean is that I couldn’t link out. How would this be done?

    eg:
    function my_custom_login_url() {
    return site_url(‘http://www.site.com’);
    }
    add_filter( ‘login_headerurl’, ‘my_custom_login_url’, 10, 4 );

    • http://lucatironi.net Luca Tironi

      Thanks, but you “are doing it wrong”!

      The function site_url() returns the actual url of your wordpress site (e.g. http://primegap.net in our case), but if you want to link the logo to another url, just write:

      function my_custom_login_url() {
      return 'http://www.site.com';
      }
      add_filter( 'login_headerurl', 'my_custom_login_url', 10, 4 );

      Check out the the WordPress Codex about the site_url() function.

      Bye and thanks for the feedback.

  • Doc Holiday

    You talk loads of shit and do nothing.

    Looks they same, ya moron: http://primegap.net/wp-login.php

    Walk the talk or shut the fuck up!

    • http://lucatironi.net Luca Tironi

      You are right. I used that functions on the previous version of the site and never re-imported them in the current one.

      Now we are not talking about shit anymore, check it out: http://primegap.net/wp-login.php

      That’s the actual code straight from the quick tip.

      Enjoy.

  • Sally

    Thanks for the tip Luca, just what I was after.

  • http://www.newjerseysfactory.com concellnon

    Thanks for help~

  • http://www.superzero.org Paolo

    Hi, I updated to WordPress 3.3.1 and the custom login is gone… Do you have suggestion?
    Thanks
    Paolo

    • http://lucatironi.net Luca Tironi

      I’m sorry but I didn’t had the time to update the tutorials for the new WP versions. If I will look into it in the near future, I’ll let you know.

  • Chad

    I believe you may also use bloginfo(‘url’)/whateverpageyouwanttogoto; for a url path.

  • stva

    and what about cosing out the poewered by wordpress on mouseover of image :-)

  • stva

    nva mond got it.. add this to custom logo, edit url to your own and mouseover powered by
    -=-=
    function my_custom_login_logo() {
    echo ‘
    h1 a { background-image:url(‘.get_bloginfo(‘template_directory’).’/images/logo-login.png) !important; }
    ‘;
    }

    add_action(‘login_head’, ‘my_custom_login_logo’);

    function my_custom_login_url() {
    return site_url();
    }
    add_filter( ‘login_headerurl’, ‘my_custom_login_url’, 10, 4 );

    function login_header_title()
    {
    return get_bloginfo(‘name’);
    }

    add_filter(“login_headertitle”,”login_header_title”);

  • Pingback: Custom wordpress login logo | state0fmind()

  • Pingback: 30+ How to’ s.. plugins, themes, tips for WordPress | Phire Base - Graphic, Webdesign, Inspiration. Adobe & WP()

  • juandartez

    Hi, I have a problem with that code, I am using wordpress version 3.2 I get the following error: Fatal error: Call to undefined function add_action () in C: xampp htdocs blog wp-includes functions.php on line 31
    is not the function add_action () someone could tell me iplese what is the problem?

  • http://www.sjtapechina.com bag sealing tape

    thank you very much… Good.

  • Nadeeka

    Thanks, Great job

  • Paul

    Thanks for the great write-up.

    @Doc Holiday – Shut the fuck up! I don’t see you walking the walk with your fake name and all that shit!

  • http://www.libin.in Libin

    Nice tutorial..
    Now you can customize completly your WordPress Login Screen and Dashboard easily with “Erident Custom Login and Dashboard” plugin. You can Add your logo, change background images, colors, styles ,Dashboard footer etc. from the plugin’s settings page.

    Check it: http://wordpress.org/extend/plugins/erident-custom-login-and-dashboard/

    • Kimba

      Thank you very much, your plugin is excellent.

  • Timmy

    Great tip, thanks!

  • http://www.aMUSINGjames.com jimmyjames

    Worked like a charm. Cheers!