Skip to content

Instantly share code, notes, and snippets.

@morgyface
Last active October 21, 2020 15:12
Show Gist options
  • Save morgyface/040dbac37e4c2edc53eeddf879242ee1 to your computer and use it in GitHub Desktop.
Save morgyface/040dbac37e4c2edc53eeddf879242ee1 to your computer and use it in GitHub Desktop.
WordPress | Login customisation
<?php
// Add the login styles
function add_login_scripts() {
/**
* login_enqueue_scripts is the proper hook to use when enqueuing items that
* are meant to appear on the login page.
*/
wp_enqueue_style( 'core', get_stylesheet_directory_uri() . '/assets/css/login.min.css', array('login') );
}
add_action( 'login_enqueue_scripts', 'add_login_scripts' );
// If we are changing the login logo, it makes sense to also change the URL
function add_login_logo_url() {
return home_url();
}
add_filter( 'login_headerurl', 'add_login_logo_url' );
@morgyface
Copy link
Author

Here's some supporting CSS

body.login {
  background-color: #E4EBF0;
}

body.login div#login h1 a {
  background-image: url(../img/logo.svg);
  background-image: none, url(../img/logo.svg);
  -webkit-background-size: auto 84px;
  background-size: auto 84px;
  width: 122px;
  height: 84px;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment