DevTeam-Admin
3/26/2020 - 11:06 PM

WordPress Login Screen Customization Functions

Snippet of functions to customize the wp-admin screen/login screen of WordPress. The snippets below are to customize the image, image url, and image title attribute.

This code snippets should be placed in functions.php or subfile that is being included into the functions.php

/**
 * Customize WP login Logo
 *
 * Customize the logo on the wp-admin login page
 * Default: WordPress logo
 */
 
function theme_login_logo() { 
    echo '<style type="text/css">
        #login h1 a, .login h1 a {
            background-image: url('.get_stylesheet_directory_uri().'/images/logo.svg);
            padding-bottom: 20px; // example CSS, customize as necessary
			      background-size: 95%;
			      width: 99%;
			      height: 35px;
        }
        #login .button.button-primary {
            background-color: #248A83; // customize login button to client's colour palette
            border-color: #248A83;
        }
    </style>';
}
add_action( 'login_enqueue_scripts', 'theme_login_logo' );

/**
 * Customize WP login Logo Url
 *
 * Changes default url to the front-page of the site instead.
 * Default: wordpress.org
 */

function theme_login_logo_url() {
    return home_url();
}
add_filter( 'login_headerurl', 'theme_login_logo_url' );

/**
 * Customize WP login Logo Title
 *
 * Customize the title attribute on the logo on the wp-admin login screen
 * Default: wordpress.org
 */

function theme_login_logo_url_title() {
    return 'Company Title Co.';
}
add_filter( 'login_headertitle', 'theme_login_logo_url_title' );