How to change the WordPress Login image and URL

Screen Shot 2013-09-06 at 15.54.53There’s a great little plugin called Add Logo to Admin by c.bavota which does a great job at letting you add your own logo to the WordPress login screen, and even to the top of your dashboard. But it’s another plugin.

If you’re building a theme for a client and simply want to replace the generic WordPress image, you can do that with just a few lines of code. Place them in your theme’s functions.php file:

//Change the generic login image
function custom_login_logo() {
  echo '<style type="text/css">
    h1 a { background-image:url('.get_bloginfo('stylesheet_directory').'/path-to-your/image.png) !important; }
    </style>';
}
add_action('login_head', 'custom_login_logo');

Discovered in Jo Lowery’s excellent course Dreamweaver and WordPress Core Concepts at Lynda.com.

Change the Login URL

Now that the logo says something other than WordPress, it’s probably confusion that when someone were to click, they’d still go to WordPress.org – rather than a custom URL.

Let’s fix that by adding this code:

// add custom URL to Login Logo
function custom_login_url(){
    return ('http://example.com/');
    }
    add_filter('login_headerurl', 'custom_login_url');

Happy styling!

Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or drawing on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.