Post Pic

Customize WordPress login logo without a plugin

WordPress login logo looks nice, but sometimes you may want to change it, for example when building a site for a client. In that case, you can use a plugin, or simply take advantage of this cool hack.

Nothing hard with this recipe. The only thing you have to do is to copy the following piece of code, and paste it on your functions.php file:

function my_custom_login_logo() {
    echo '<style type="text/css">
        h1 a { background-image:url('.get_bloginfo('template_directory').'/images/custom-login-logo.gif) !important; }
    </style>';
}

add_action('login_head', 'my_custom_login_logo');

This hack has been submitted by Rami. Thanks for your contribution!

8 Responses

Aug 02 2011 18:51

This is one of my favourite, simple WordPress hacks.

Aug 03 2011 14:05

It does not work properly … the image does not fit correctly despite being a proper wordpress login screen !

Aug 03 2011 20:35

This is very simple. Kill plugins. :)

Aug 03 2011 22:56

Maybe citing the original source would be better: http://primegap.net/2011/01/26/wordpress-quick-tip-custom-wp-login-php-logo-url-without-hacks/

Aug 03 2011 23:02

Nevermind, I just saw that the original post on the contributor’s site is from 2009 (sorry I didn’t check and I cannot read hebraic).

My bad. Interestingly we came basically to the same code! I just don’t remember where I found the documentation to create this hack, so maybe we drew from the same sources.

Our quick tip has also another function to add a custom url to the custom logo, if you need to.

Oct 28 2011 02:58

Hi there. I know there is something in the codex regarding this. I actually edited the article with the code mentioned above this past week.

If you’d like the source, I could look.

Dec 25 2011 20:40

This code works fine.

I tested it on a Twenty Eleven Child Theme 25/12/2011

Feb 02 2012 09:48

youll need url edited also and mouse over powered by wordpress
-=-=-=
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”);

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required