← Back to All Snippets

Replace WordPress Login Logo and Link with Custom Site Logo

⚡ Target: functions.php 🔒 Tested: WP 6.6+ / PHP 8.2+ 💻 Lang: PHP
PHP (functions.php)
// 1. Change Login Logo URL to Homepage
add_filter( 'login_headerurl', function() {
    return home_url();
} );

// 2. Change Login Logo Tooltip Title
add_filter( 'login_headertext', function() {
    return get_bloginfo( 'name' );
} );

// 3. Inject Custom Logo CSS
add_action( 'login_enqueue_scripts', function() {
    $custom_logo_id = get_theme_mod( 'custom_logo' );
    $logo_url = $custom_logo_id ? wp_get_attachment_image_url( $custom_logo_id, 'medium' ) : '';
    if ( ! $logo_url ) return;
    ?>
    <style type="text/css">
        #login h1 a, .login h1 a {
            background-image: url('<?php echo esc_url( $logo_url ); ?>');
            background-size: contain;
            background-position: center;
            background-repeat: no-repeat;
            width: 100%;
            height: 80px;
            margin-bottom: 20px;
        }
    </style>
    <?php
} );

White-label the wp-login.php screen with your own custom logo and redirect the logo click to your homepage instead of WordPress.org.

← Back to All Snippets Explore Dev Tools →