login_head WordPress Action Hook

The login_head hook is used to call the wp_head function, which includes the default WordPress stylesheet, the default WordPress JavaScript files, and any other scripts and stylesheets included by the theme or other plugins.

do_action( 'login_head' ) #

Fires in the login page header after scripts are enqueued.


More Information

This filter can be used to add anything to the <head> section on the login page.

You can customise the login form using login_head fairly easily.

Add the following code to functions.php in your theme:

// custom login for theme
function childtheme_custom_login() {
	echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('stylesheet_directory') . '/customlogin.css" />';
}
 
add_action('login_head', 'childtheme_custom_login');

This has the effect of adding a reference to a stylesheet to your login form.

You will then need to add a stylesheet called customlogin.css to your theme directory.

For testing purposes, this should start you off:

html {
background-color: #f00;
}

This should produce a login background.

Here we replace the standard WordPress logo with our logo, taken from our theme (this uses get_stylesheet_directory_uri to work with child themes):

function my_custom_login_logo() {
     echo '<style type="text/css">                                                                   
         h1 a { background-image:url('.get_stylesheet_directory_uri().'/images/login.png) !important; 
         height: 120px !important; width: 410px !important; margin-left: -40px;}                            
     </style>';
}
add_action('login_head', 'my_custom_login_logo');

To set the URL of the login icon’s link, see login_headerurl


Top ↑

Source

File: wp-login.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
2.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.