Skip to content

Instantly share code, notes, and snippets.

@warderer
Created December 29, 2021 06:09
Show Gist options
  • Select an option

  • Save warderer/efed38a2b32f4ffc8d856fb80da197a5 to your computer and use it in GitHub Desktop.

Select an option

Save warderer/efed38a2b32f4ffc8d856fb80da197a5 to your computer and use it in GitHub Desktop.
[Custom Logo and Background on Wordpress Login] Simple enhacement changing the wp-login view with a custom logo and a background color via template functions.php on #wordpress
/* = Customize login page
Reference: https://sgwebpartners.com/es/how-to-customize-login-logo-on-wordpress/
---------------------------------------------------- */
function sgwp_custom_login_logo(){
echo
"<style type='text/css'>
body.login { background-color: #00629e; } //LOGIN BACKGROUND COLOR HERE
body.login h1 a { background-image: url(". get_site_url() ."/wp-content/uploads/2021/00/LOGO_FILE_URL_HERE.PNG);
background-size: 162px 80px; width: 162px; height: 80px; }
body.login p#backtoblog, body.login p#nav, body.login .privacy-policy-page-link { background-color: white; margin-top:0px; margin-bottom: 0px; padding: 15px 15px; }
body.login .privacy-policy-page-link { padding: 15px 0; }
</style>";
}
function sgwp_custom_login_url(){
return get_option('home');
}
function sgwp_custom_login_title(){
return get_option('blogname');
}
add_action('login_head', 'sgwp_custom_login_logo');
add_filter('login_headerurl', 'sgwp_custom_login_url');
add_filter('login_headertext', 'sgwp_custom_login_title');
function is_login_page(){
return in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment