login_enqueue_scripts

Home » Hooks » login_enqueue_scripts

The login_enqueue_scripts hook is a WordPress action hook that allows developers to enqueue styles and scripts for the login page. This hook is useful for adding custom styles or scripts to the login page, such as a custom login logo or a custom login form.

By using this hook, developers can ensure that their custom styles and scripts are only loaded on the login page, rather than being loaded on every page of the site. This can help to improve the performance of the site by reducing the amount of unnecessary code that is loaded.

Here’s an example usage of the login_enqueue_scripts hook:

function my_custom_login_styles() {
    wp_enqueue_style( 'my-login-styles', get_stylesheet_directory_uri() . '/css/login-styles.css' );
}
add_action( 'login_enqueue_scripts', 'my_custom_login_styles' );

In this example, we’re using the wp_enqueue_style() function to enqueue a custom stylesheet for the login page. The stylesheet is located in the /css/ directory of the active theme, and is named login-styles.css. We’re adding this custom stylesheet to the login page by using the login_enqueue_scripts hook and calling the my_custom_login_styles() function.

Learn More on WordPress.org

WordPress snippets using the login_enqueue_scripts hook

Register an account to save your snippets or go Pro to get more features.