How to change WordPress default login page logo?

Here is a simple trick to change WordPress default login page logo, logo url link and url title.

In various cases I found many users don’t want WordPress default logo on their WordPress login page and searching for suitable code to replace logo with their website logo. So here is a full tutorial to modify login page as per user requirement.

Add the below code to your theme/child theme functions.php file:

/*
* change login image.
* Ex: Screenshot
*/
function fn_change_login_image() {
      echo “<style>
       body.login #login h1 a {
      background: url(‘”.get_stylesheet_directory_uri().”/images/saurabh-logo.png’) no-repeat scroll center top / 75px auto;
      }
      </style>”;
}
add_action(“login_enqueue_scripts”, “fn_change_login_image”);

Add below code to change the link value so the logo links to your WordPress site:

/*
* To change the link values so the logo links to your WordPress site.
*/
function fn_login_logo_url() {
      return home_url();
}
add_filter( ‘login_headerurl’, ‘fn_login_logo_url’ );

Add below code to change the title of the login page logo url:

/*
* To change the title of the login page logo url.
*/
function fn_login_logo_url_title() {
      return ‘Saurabh Dixit: Personal portfolio website.’;
}
add_filter( ‘login_headertitle’, ‘fn_login_logo_url_title’ );

That’s it, go to your website login page and refresh the page, and I am sure you will see a result. 😀

Note: For any questions, doubt or suggestion please add comment below or drop me a message here.

Leave a Reply

Your email address will not be published. Required fields are marked *