• Skip to primary navigation
  • Skip to main content
Daniel McClure

Daniel McClure

Entrepreneurship, Marketing, Technology, Travel & Lifestyle

  • About
  • Credentials
  • The Blog of Daniel McClure
  • Social
  • Code
  • Contact
  • GitHub
  • Instagram
  • LinkedIn
  • Twitter

Cheatsheet for customising the WordPress Login page

Code snippet posted to GitHub Gist by Daniel McClure.

You are here: Home » Code Snippets » #CSS » Cheatsheet for customising the WordPress Login page

Last Updated: December 13, 2018 Leave a Comment

The following is a code snippet originally posted by Daniel McClure on GitHub as a Gist.

functions.php

“`
‘;
}
add_action(‘login_head’, ‘my_custom_login’);
function my_login_logo_url() {
return get_bloginfo( ‘url’ );
}
add_filter( ‘login_headerurl’, ‘my_login_logo_url’ );
function my_login_logo_url_title() {
return ‘Your Site Name and Info’;
}
add_filter( ‘login_headertitle’, ‘my_login_logo_url_title’ );
function login_error_override() {
return ‘Incorrect login details.’;
}
add_filter(‘login_errors’, ‘login_error_override’);
function admin_login_redirect( $redirect_to, $request, $user ) {
global $user;
if( isset( $user->roles ) && is_array( $user->roles ) ) {
if( in_array( “administrator”, $user->roles ) ) {
return $redirect_to;
} else {
return home_url();
}
} else {
return $redirect_to;
}
}
add_filter(“login_redirect”, “admin_login_redirect”, 10, 3);
“`

style.css

“`
html {
height: 100%;
background: #ffffff url(‘ENTER_URL’) no-repeat center top fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

body {
background: none;
min-width: 0;
padding-top: 8%;
color: #FFF;
}

#login {
background-color: #ffffff;
border: 0 solid #ffffff;
-webkit-border-radius: 11px;
border-radius: 11px;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
background-color: rgba(255,255,255,0.85);
padding: 15px 20px;
}

.login #login_error,
.login .message {
background-color: #444;
}

.login h1 a {
background-image: url(‘ENTER_URL’);
background-size:auto;
width: 300px;
height: 132px;
}
“`

Original Gist


<?php
// Cheatsheet for customising the WordPress Login page
function my_custom_login() {
echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('stylesheet_directory') . '/login/ENTER_URL.css" />';
}
add_action('login_head', 'my_custom_login');
function my_login_logo_url() {
return get_bloginfo( 'url' );
}
add_filter( 'login_headerurl', 'my_login_logo_url' );
function my_login_logo_url_title() {
return 'Your Site Name and Info';
}
add_filter( 'login_headertitle', 'my_login_logo_url_title' );
function login_error_override() {
return 'Incorrect login details.';
}
add_filter('login_errors', 'login_error_override');
function admin_login_redirect( $redirect_to, $request, $user ) {
global $user;
if( isset( $user->roles ) && is_array( $user->roles ) ) {
if( in_array( "administrator", $user->roles ) ) {
return $redirect_to;
} else {
return home_url();
}
} else {
return $redirect_to;
}
}
add_filter("login_redirect", "admin_login_redirect", 10, 3);

view raw

functions.php

hosted with ❤ by GitHub


html {
height: 100%;
background: #ffffff url('ENTER_URL') no-repeat center top fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
body {
background: none;
min-width: 0;
padding-top: 8%;
color: #FFF;
}
#login {
background-color: #ffffff;
border: 0 solid #ffffff;
-webkit-border-radius: 11px;
border-radius: 11px;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
background-color: rgba(255,255,255,0.85);
padding: 15px 20px;
}
.login #login_error,
.login .message {
background-color: #444;
}
.login h1 a {
background-image: url('ENTER_URL');
background-size:auto;
width: 300px;
height: 132px;
}

view raw

style.css

hosted with ❤ by GitHub

Filed Under: GitHub Gist Tagged With: #CSS, #PHP, #Wordpress

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *

You can encrypt your comment so that only Daniel McClure can read it.

Daniel McClure

Work With Me

Get in touch if you’re interested in working together on your next project.

Contact Me

Creative Commons Licence

Copyright © 2025 Daniel McClure

All opinions shared through this site are that of their respective author and are not necessarily representative of the views of past/present clients, affiliate partners or businesses.
Some links include affiliate tracking for which I may earn a commission. See the Full Disclaimer Page for more information.