# Use the Main Site's Icon on Sites Without One

> Makes subsites that have no Site Icon of their own show the main site's favicon and app icon, so every browser tab carries your brand.

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

## Code

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

add_filter( 'get_site_icon_url', function ( $url, $size, $blog_id ) {
    $main = get_main_site_id();

    if ( $url || (int) $blog_id === $main || ( ! $blog_id && is_main_site() ) ) {
        return $url;
    }

    $key    = 'wpide_main_icon_' . (int) $size;
    $cached = wp_cache_get( $key, 'wpide' );

    if ( false === $cached ) {
        $icon_id = (int) get_blog_option( $main, 'site_icon' );
        $cached  = '';
        if ( $icon_id ) {
            switch_to_blog( $main );
            $cached = (string) wp_get_attachment_image_url( $icon_id, array( $size, $size ) );
            restore_current_blog();
        }
        wp_cache_set( $key, $cached, 'wpide', HOUR_IN_SECONDS );
    }

    return $cached ? $cached : $url;
}, 10, 3 );
```

## Notes

Sites that upload their own icon keep it.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Use the Main Site's Icon on Sites Without One" 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/
