# Network-Wide Login Logo From the Main Site

> Shows the main site's custom logo on the login screen of every site in the network, linked to the site being logged in to.

- Type: PHP
- Runs: Run everywhere
- Category: [Multisite](https://wpide.com/library/category/multisite/)
- Tags: login, logo, branding
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/ms-network-login-logo/

## Code

```php
if ( ! is_multisite() ) {
    return;
}

add_action( 'login_enqueue_scripts', function () {
    $main    = get_main_site_id();
    $mods    = get_blog_option( $main, 'theme_mods_' . get_blog_option( $main, 'stylesheet' ) );
    $logo_id = is_array( $mods ) && ! empty( $mods['custom_logo'] ) ? (int) $mods['custom_logo'] : 0;

    if ( ! $logo_id ) {
        return;
    }

    switch_to_blog( $main );
    $src = wp_get_attachment_image_src( $logo_id, 'medium' );
    restore_current_blog();

    if ( ! $src ) {
        return;
    }

    $width  = min( 320, (int) $src[1] );
    $height = $src[1] ? (int) round( $src[2] * $width / $src[1] ) : 84;

    printf(
        '<style>.login h1 a{background-image:url(%1$s);background-size:contain;background-position:center;width:%2$dpx;height:%3$dpx;max-width:100%%}</style>',
        esc_url( $src[0] ),
        (int) $width,
        (int) $height
    );
} );

add_filter( 'login_headerurl', function () {
    return home_url( '/' );
} );

add_filter( 'login_headertext', function () {
    return get_bloginfo( 'name' );
} );
```

## Notes

Uses the main site's Customizer logo (custom_logo); set one there first.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Network-Wide Login Logo From the Main Site" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
