Home » Hooks » login_head

The WordPress hook "login_head" is a powerful tool that allows developers to manipulate the content of the login page header. This hook is fired right before the closing head tag of the login page HTML, providing the opportunity to add custom CSS, JavaScript, or any other code to modify the appearance or functionality of the login page.

The "login_head" hook is commonly used to customize the login page to match the branding or design of a website, or to add additional login features such as a custom logo, background image, or even interactive elements like animations or tooltips.

Here’s an example usage of the "login_head" hook:

function custom_login_head() {
    // Add custom CSS to style the login page
    echo '<style>
        body.login {
            background-color: #f1f1f1;
        #login h1 a {
            background-image: url("path/to/custom-logo.png");
            background-size: contain;
            width: 200px;
            height: 100px;

    // Add custom JavaScript for additional functionality
    echo '<script>
        // Add your custom JavaScript code here
add_action('login_head', 'custom_login_head');

In this example, we define a custom function called "custom_login_head" that echoes both a custom CSS block and a custom JavaScript block. The CSS code sets the background color of the login page to light gray and adds a custom logo to the login form. The JavaScript block can be used to add any additional custom functionality you want to implement on the login page.

By using the "login_head" hook and adding our custom function to it using the "add_action" function, we ensure that our customizations will be applied to the login page every time it is loaded.

Remember, the possibilities with the "login_head" hook are endless. You can use it to create a completely personalized login page that aligns with your website’s design and branding, or to add custom functionality to enhance the user experience during the login process.

Learn More on WordPress.org

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