Categories
Wordpress

Customise Login Page in WordPress

To customise your WordPress login area, typically on this URL your-domain.com/wp-login.php, you need to add the following in your theme’s function.php file.

Change the login Logo

The default image is the WordPress logo. You can change that image simply modifying the file path. You can add you image and adjust width and height if necessary.

function custom_login_logo() {
    echo '<style type="text/css">
    h1 a { 
        background: url('.get_bloginfo('template_directory').'/img/logo.png) 50% 0% no-repeat !important;
        background-size: contain !important;
        width:260px !important; 
        height:90px !important; 
        margin:0 auto !important; 
    }
    </style>';
}
add_action('login_head', 'custom_login_logo');

 Change the login URL of the login logo

Normally when you click on the login logo, by default it goes to WordPress.org. The following will change it to your own homepage.

function change_wp_login_url(){ 
	return get_bloginfo('url');
}
add_filter('login_headerurl', 'change_wp_login_url');

Change the Title of the login logo

If you want to change the title attribute of the image you just replaced use the following code.

function change_wp_login_title(){ 
	return get_option('blogname'); 
}
add_filter('login_headertitle', 'change_wp_login_title');