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