Customize Your WordPress Login Page with Your Brand Logo (No Plugin Needed)
Want to replace the boring WordPress login logo with your own brand logo? Here's how you can do it in seconds using the logo uploaded via the WordPress Customizer. No plugin required, just clean and efficient code!
👨💻 Add This Code to Your Theme's functions.php
add_action('login_enqueue_scripts', 'custom_login_logo_from_customizer');
function custom_login_logo_from_customizer() {
// Get the custom logo ID
$custom_logo_id = get_theme_mod('custom_logo');
if ($custom_logo_id) {
$logo_url = wp_get_attachment_image_url($custom_logo_id, 'full');
?>
<style type="text/css">
body.login div#login h1 a {
background-image: url('<?php echo $logo_url; ?>');
background-size: contain;
width: 100%;
height: 80px;
}
</style>
<?php
}
}
add_filter('login_headerurl', function() {
return home_url(); // Redirect to site home instead of wordpress.org
});
add_filter('login_headertext', function() {
return get_bloginfo('name');
});
🎯 What This Code Does
- Pulls the logo from your Customizer settings (Customizer > Site Identity > Logo).
- Replaces the WordPress login logo with your logo.
- Sets the login logo link to your site's homepage.
- Sets the hover title text to your site’s name.
💡 Bonus Tip
Make sure your theme supports custom_logo
. Most modern themes do.
0 Comments