Yogesh Chauhan's Blog

How to change the Login Logo in WordPress?

in WordPress on March 3, 2021

I am talking about logo on top of this login form:

WordPress login page

There are multiple ways to change the WordPress logo on the admin login page. We can change it using code to the Theme’s functions.php file.

To change (or replace) the WordPress logo we need to modify the CSS styles related to this heading:



<h1>
  <a href="https://wordpress.org/">
    Powered by WordPress
  </a>
</h1>


As you can see in the code above, WordPress has a logo link which is inside the h1 tag. WordPress then styles using CSS to set and display the WordPress logo as a background image.

WordPress has tons of functions for e.g. get_posts, apply_filters, add_filter just to name a few.

To insert the CSS style, we can use the login_enqueue_scripts hook. Using that style we replace the logo with ours.

Use this code to change the logo:


function my_login_logo() { 
  ...
  //add style here
  ...
}
add_action( 'login_enqueue_scripts', 'my_login_logo' );


#login h1 a,
.login h1 a {
  background-image : url(wp-contents/themes/your-theme/images/site-login-logo.png);
  height           : 65px;
  width            : 320px;
  background-size  : 320px 65px;
  background-repeat: no-repeat;
  padding-bottom   : 30px;
}

Since you’re adding style in a file without a .css extension, you need to specify the type of the code and then add the code inside these tags:



<style type="text/css">
...
//your style goes here
...
</style>


Just like this code screen capture:

WP login logo change function

In the code above, change the file named logo.png with your logo file name. Also, put your logo in a directory named /img in your active Theme files.

WordPress suggests that the size of the logo should not be bigger than 80px by 80px but we can change that using the style in the code above as per our needs.

We can also change the link so that we can direct users on click on the logo image.

Use this hook to change the link. Make sure to add the code below after the logo change code we saw above.


function my_login_logo_url() {
    return home_url();
}
add_filter( 'login_headerurl', 'my_login_logo_url' );

function my_login_logo_url_title() {
    return 'Your Site Name and Info';
}
add_filter( 'login_headertitle', 'my_login_logo_url_title' );

Credit goes to WP Docs


Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Aug 15 Is PHP still good for back-end programming? #Aug 10 How to create a multisite network in WordPress? #Aug 3 How to create a circle that follows a cursor using JavaScript and CSS? #Aug 3 How to make a curtain slider using jQuery and CSS? #Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS?
You might also like these
WordPress Plugin: Things to knowWordPressHow to create a multisite network in WordPress?WordPressThe Sort and Compare Functions in JavaScriptJavaScriptHow to create a pricing table using flex in CSS?CSSHow to modify navigation menus in WordPress?WordPressHow to show widgets on the Appearance tab in WordPress?WordPress