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.
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