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!

36 Responses

Dec 21 2009 13:27

I’m going to do this on all of my client sites – it’s one of those little extras that’s well worth it!

Dec 21 2009 22:08

That’s a very cool idea. Will that get replaced when you update your wordpress core?

Dec 22 2009 00:13

@Nicholas Cardot : Not at all, this is the very good point of this method :)

Dec 22 2009 00:56

How about if I wanted to change the title or link attribute of the custom logo, instead of the default “Powered by Wordpress” and link to wordpress.org?

Is that possible through the functions method?

Dec 22 2009 01:09

This is brilliant, i’ve been looking for something like this. :)

Cheers!

Dec 22 2009 06:10

It doesn’t appear to change the link though (it still links to wordpress.org)… any way to change that too?

Dec 22 2009 13:58

Good little recipe and great for premium theme providers and business client developed themes. Thanks for posting it :)

Dec 22 2009 21:51

I have the same question as Matt and p, how do we change the link?

Bit pointless in changing the logo if it links to wordpess.org imo!

Dec 23 2009 15:39

I like the idea… it will be like my own login :)

Dec 23 2009 18:25

@p, @Thomas:

Here’s how to change the Link & Title attributes for a custom logo.

//Custom Login Screen
function change_wp_login_url() {
echo bloginfo(‘url’);
}

function change_wp_login_title() {
echo get_option(‘blogname’);
}

add_filter(‘login_headerurl’, ‘change_wp_login_url’);
add_filter(‘login_headertitle’, ‘change_wp_login_title’);

Put that in your functions.php file

Dec 23 2009 22:02

Cheers Matt, had a feeling there was a hook somewhere! Makes this post a whole lot more useful now!
Happy Holidays.

Dec 24 2009 03:59

that’s a cool little trick, thanks.

Dec 30 2009 00:12

I just wrote an article a few days ago on how to change the look using a plugin (which works really well). But this is a great alternative for those not wanting to mess with any plugins.

Dec 30 2009 00:28

This is perfect when combined with Matt’s code to change URL and Title.

Dec 30 2009 08:26

I’d love to see this as a simple plugin with input fields for the image location url and the link of the image… anyone? :)

Jan 01 2010 12:10

I was looking for this for a long time thanks for the tip

Jan 05 2010 13:25

excellent tip!! thanks for sharing!

Jan 06 2010 15:10

Many thanks, this small things makes a big difference wen presenting the site to a customer ;)

Jan 06 2010 21:10

I’m getting this warning:

Warning: Cannot modify header information – headers already sent by (output started at /home/look/public_html/wp/wp-content/themes/wp-theme/functions.php:61) in /home/look/public_html/wp/wp-login.php on line 290

Warning: Cannot modify header information – headers already sent by (output started at /home/look/public_html/wp/wp-content/themes/wp-theme/functions.php:61) in /home/look/public_html/wp/wp-login.php on line 302

My custom logo appears but that appears as well.

What did I do wrong?

Jan 07 2010 18:45

I have solved my problem. It seems that this is a common problem when editing the functions file.

Make sure there is absolutely no white space after the close of your php tag. I had a few extra spaces (line 290 was just a blank line). I deleted the blank stuff and everything worked perfectly.

Jan 07 2010 22:30

Very neat piece of code creating a big impression! Great tip!

Jan 10 2010 00:46

Cool tip that seems very easy to do. I am amazed at how much can be modified using functions.php.

Feb 21 2010 00:35

HEY could anyone tell me if i upgrade to any other 2.x wordpress version ,would my customizations get wiped off?

As in, all efforts in vain?

Please let me know

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required