Archived topic
how to change the colour of the admin login page background
8 replies · Started by nomadiceman on July 16, 2021
Hi guys, Ive used this awesome code snippet from Tom to get my logo in the admin area. It works great
add_filter( 'login_headerurl', function() {
return site_url();
} );
add_filter('login_headertitle', function() {
return get_bloginfo( 'name' );
} );
add_action( 'login_enqueue_scripts', function() {
$logo = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' );
$logo_url = $logo[0];
?>
<style type="text/css">
#login h1 a, .login h1 a {
background-image: url(<?php echo $logo_url; ?>);
height:65px;
width:320px;
background-size: 320px 65px;
background-repeat: no-repeat;
}
</style>
<?php
} );
Is there anyway to change the background colour of the admin page too? The standard is that grey colour. Would be great to be able to change that
Any code to do that?
Hi there,
the background to the login page - try this CSS:
body.login {
background-color:#f00;
}
Thanks David. I’ll give that a go 🙏
You're welcome
Ok so I got confused here. Originally I thought I just added the CSS site wide in the appearance CSS , but I believe I add it in the snippet.
Im using the background colour as #794fff.
So is this correct? It seems to work, I just wanted to check that I've put the CSS in the correct place
add_filter( 'login_headerurl', function() {
return site_url();
} );
add_filter('login_headertitle', function() {
return get_bloginfo( 'name' );
} );
add_action( 'login_enqueue_scripts', function() {
$logo = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' );
$logo_url = $logo[0];
?>
<style type="text/css">
#login h1 a, .login h1 a {
background-image: url(<?php echo $logo_url; ?>);
height:65px;
width:320px;
background-size: 320px 65px;
background-repeat: no-repeat;
}
body.login {
background-color:#794fff;
}
</style>
<?php
} );
Also, using the code snippet plugin, do I run this snippet everywhere even though its only used for the login page?
The way you added the code is correct.
Leave it as Run Everywhere.
Thanks David
Awesome 👍
Glad to be of help