Last updated on September 13, 2023

Change Login Logo

Don’t know where to add this snippet? Read our guide: How to add code snippets.

Change the logo on the WordPress login page.

If you want to add a custom logo to the WordPress login page, it’s possible to do so using CSS. To change the default WordPress login logo, you can use the login_head action hook.

A screenshot of the WordPress login page showing a custom logo (The WP Snippets logo) instead of the default WordPress logo.
It’s possible to change the logo on the WordPress login page through CSS.

The following code snippet will replace the WordPress logo with your own custom logo:

<?php

function wpsnippets_login_logo() {

   ?><style type="text/css">

        body.login #login h1 a {
            background-image: url('<?php echo get_stylesheet_directory_uri(); ?>/images/logo.png');
            background-size: 100%;
            width: 300px;
        }

    </style><?php

}

add_action( 'login_head', 'wpsnippets_login_logo' );

Replace custom-login-logo.png with the filename of your custom logo, and adjust the width and height to match your logo’s dimensions. This code uses the get_stylesheet_directory_uri() function to get the URL of your theme’s directory, and it assumes that your custom logo is located within the /images directory within your theme’s folder. Change the URL to the image file according to where your image file is uploaded.

Last updated on September 13, 2023. Originally posted on May 3, 2023.

Leave a Reply

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