Skip to content

Instantly share code, notes, and snippets.

@mattneal-stafflink
Created June 2, 2021 23:18
Show Gist options
  • Save mattneal-stafflink/37486608fa097b1ae5dca711ddd4a5a2 to your computer and use it in GitHub Desktop.
Save mattneal-stafflink/37486608fa097b1ae5dca711ddd4a5a2 to your computer and use it in GitHub Desktop.
Style the /wp-login page and form.
<?php
/**
* Change logo and branding of the WordPress login page.
* Replace the background Image URL CSS element to update the image.
* Ensure you have a file called style-login.css in the root directory of your child theme.
*
* @since 1.0.0
*/
function my_login_logo() {
echo '
<style type="text/css">
#login h1 a, .login h1 a {
background-image: url(/wp-content/uploads/sites/4/2021/05/image-property-logo.png);
height: 70px;
width: 100%;
background-size: contain;
background-repeat: no-repeat;
padding-bottom: 30px;
}
</style>';
}
add_action( 'login_enqueue_scripts', 'my_login_logo' );
/**
* Update the home URL to be the home page, not wordpress.org.
*/
function my_login_logo_url() {
return home_url();
}
add_filter( 'login_headerurl', 'my_login_logo_url' );
/**
* Change the title of the login URL. Change the content of the returned text.
*/
function my_login_logo_url_title() {
return 'Image Property learning Hub';
}
add_filter( 'login_headertitle', 'my_login_logo_url_title' );
/**
* Load a file called style-login.css on the login screen so we can add custom css.
*/
function my_login_stylesheet() {
wp_enqueue_style( 'custom-login', get_stylesheet_directory_uri() . '/style-login.css' );
}
add_action( 'login_enqueue_scripts', 'my_login_stylesheet' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment