Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonlk/3998938 to your computer and use it in GitHub Desktop.
Save simonlk/3998938 to your computer and use it in GitHub Desktop.
Wordpress - change login image, login url and url title
// add this to your themes functions.php file
// change login image
add_action("login_head", "my_login_head");
function my_login_head() {
echo "
<style>
body.login #login h1 a {
background: url('".get_bloginfo('template_url')."/assets/img/image-name.png') no-repeat scroll center top transparent;
height: 59px;
}
</style>
";
}
// Change title for login screen
add_filter('login_headertitle', create_function(false,"return 'URL Title';"));
// change url for login screen
add_filter('login_headerurl', create_function(false,"return home_url();"));
// change login image
add_action("login_head", "my_login_head");
function my_login_head() {
echo "
<style>
body.login #login h1 a {
background: url('".get_bloginfo('template_url')."/assets/img/image-name.png') no-repeat scroll center top transparent;
height: 59px;
}
</style>
";
}
// Change title for login screen
add_filter('login_headertitle', create_function(false,"return 'URL Title';"));
// change url for login screen
add_filter('login_headerurl', create_function(false,"return home_url();"));
@GrandRapidsWeb
Copy link

I used this snippet to change the url in my login logo. But I wanted to set it to a different site then the homepage for that particular site. So I made this tweak.

// change url for login screen
function my_login_logo_url() {
return 'http://mywebsite.com';
}
add_filter('login_headerurl', 'my_login_logo_url' );

@sallysqueak
Copy link

Hey

I tried to do this, and added it at the end of all my code already in my functions.php file, but it made the following appear at the top of my website;

// change login image add_action("login_head", "my_login_head"); function my_login_head() { echo " "; } // Change title for login screen add_filter('login_headertitle', create_function(false,"return 'URL Title';")); // change url for login screen add_filter('login_headerurl', create_function(false,"return home_url();"));

Did I do something wrong? I had to remove it without even checking whether it fixed my image problem because it looked bad on my live site :(

It would be great to know how to make this work if you could help :)

Thanks

@sallysqueak
Copy link

Ok, I got it to stop making the text appear at the top, but the code doesn't do anything it seems, I just have the wordpress logo still on the login screen :( I changed /assets/img/image-name.png to the url of the image I want, is that all I need to do or is this wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment