login_enqueue_scripts
Loads styles and scripts on the WordPress login page. The usual way to put your own logo on wp-login.php.
When it fires
login_enqueue_scripts runs on wp-login.php (the log in, lost password, registration and reset password screens) while the page's is being built. WordPress has already enqueued its own 'login' stylesheet, so you can attach inline CSS to it.
It doesn't fire on login forms built by themes or plugins, such as the WooCommerce My account page.
Parameters
None. Your callback takes no arguments.
Example: Use the site icon as the login logo
add_action( 'login_enqueue_scripts', function () {
$logo = get_site_icon_url( 192 );
if ( ! $logo ) {
return;
}
wp_add_inline_style(
'login',
sprintf(
'.login h1 a { background-image: url("%s"); background-size: contain; }',
esc_url( $logo )
)
);
} );
Good to know
- Set a site icon under Settings > General first, or the example does nothing.
- The logo links to WordPress.org by default. Change the link with the login_headerurl filter and its text with login_headertext.