Have you ever needed to change the default WordPress logo on the admin login page for a clients website? This tip will show you how without the need of a plugin.
Just paste the below code into your theme’s functions.php
file and put a replacement logo inside your theme’s images/
directory named login-logo.png
with a size of 274px x 63px
. This will add some CSS to the head of the login page that will override the WordPress login logo with our own.
1 2 3 4 5 6 7 8 9 |
/** * Custom admin login header logo */ function custom_login_logo() { echo '<style type="text/css">'. 'h1 a { background-image:url('.get_bloginfo( 'template_directory' ).'/images/login-logo.png) !important; }'. '</style>'; } add_action( 'login_head', 'custom_login_logo' ); |
It really is that easy and not a plugin in sight!
Bonus Tip: Change the login logo link URL and title attribute text
Adding the below code to your themes functions.php
file will change the login logo link URL to the home page of your blog and the title text to the blog name.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
/** * Custom admin login header link */ function custom_login_url() { return home_url( '/' ); } add_filter( 'login_headerurl', 'custom_login_url' ); /** * Custom admin login header link alt text */ function custom_login_title() { return get_option( 'blogname' ); } add_filter( 'login_headertitle', 'custom_login_title' ); |
I hope you find these tips helpful!