Title: get_site_icon_url
Published: August 18, 2015
Last modified: August 20, 2026

---

# get_site_icon_url( int $size = 512, string $url = ”, int $blog_id ): string

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/get_site_icon_url/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_site_icon_url/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_site_icon_url/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_site_icon_url/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_site_icon_url/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_site_icon_url/?output_format=md#changelog)

Returns the Site Icon URL.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_site_icon_url/?output_format=md#parameters)󠁿

 `$size`intoptional

Size of the site icon. Default 512 (pixels).

Default:`512`

`$url`stringoptional

Fallback url if no site icon is found.

Default:`''`

`$blog_id`intoptional

ID of the blog to get the site icon for. Default current blog.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_site_icon_url/?output_format=md#return)󠁿

 string Site Icon URL.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_site_icon_url/?output_format=md#source)󠁿

    ```php
    function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
    	$switched_blog = false;

    	if ( is_multisite() && ! empty( $blog_id ) && get_current_blog_id() !== (int) $blog_id ) {
    		switch_to_blog( $blog_id );
    		$switched_blog = true;
    	}

    	$site_icon_id = (int) get_option( 'site_icon' );

    	if ( $site_icon_id ) {
    		if ( $size >= 512 ) {
    			$size_data = 'full';
    		} else {
    			$size_data = array( $size, $size );
    		}
    		$attachment_url = wp_get_attachment_image_url( $site_icon_id, $size_data );
    		if ( $attachment_url ) {
    			$url = is_ssl() ? set_url_scheme( $attachment_url, 'https' ) : $attachment_url;
    		}
    	}

    	if ( $switched_blog ) {
    		restore_current_blog();
    	}

    	/**
    	 * Filters the site icon URL.
    	 *
    	 * @since 4.4.0
    	 *
    	 * @param string $url     Site icon URL.
    	 * @param int    $size    Size of the site icon.
    	 * @param int    $blog_id ID of the blog to get the site icon for.
    	 */
    	return apply_filters( 'get_site_icon_url', $url, $size, $blog_id );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/general-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/general-template.php#L1167)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/general-template.php#L1167-L1203)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_site_icon_url/?output_format=md#hooks)󠁿

 [apply_filters( ‘get_site_icon_url’, string $url, int $size, int $blog_id )](https://developer.wordpress.org/reference/hooks/get_site_icon_url/)

Filters the site icon URL.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_site_icon_url/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_get_attachment_image_url()](https://developer.wordpress.org/reference/functions/wp_get_attachment_image_url/)`wp-includes/media.php` |

Gets the URL of an image attachment.

  | 
| [is_ssl()](https://developer.wordpress.org/reference/functions/is_ssl/)`wp-includes/load.php` |

Determines if SSL is used.

  | 
| [set_url_scheme()](https://developer.wordpress.org/reference/functions/set_url_scheme/)`wp-includes/link-template.php` |

Sets the scheme for a URL.

  | 
| [switch_to_blog()](https://developer.wordpress.org/reference/functions/switch_to_blog/)`wp-includes/ms-blogs.php` |

Switches the current blog.

  | 
| [restore_current_blog()](https://developer.wordpress.org/reference/functions/restore_current_blog/)`wp-includes/ms-blogs.php` |

Restores the current blog, after calling [switch_to_blog()](https://developer.wordpress.org/reference/functions/switch_to_blog/) .

  | 
| [is_multisite()](https://developer.wordpress.org/reference/functions/is_multisite/)`wp-includes/load.php` |

Determines whether Multisite is enabled.

  | 
| [get_current_blog_id()](https://developer.wordpress.org/reference/functions/get_current_blog_id/)`wp-includes/load.php` |

Retrieves the current site ID.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

[Show 4 more](https://developer.wordpress.org/reference/functions/get_site_icon_url/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_site_icon_url/?output_format=md#)

| Used by | Description | 
| [WP_REST_Server::add_site_icon_to_index()](https://developer.wordpress.org/reference/classes/wp_rest_server/add_site_icon_to_index/)`wp-includes/rest-api/class-wp-rest-server.php` |

Exposes the site icon through the WordPress REST API.

  | 
| [do_favicon()](https://developer.wordpress.org/reference/functions/do_favicon/)`wp-includes/functions.php` |

Displays the favicon.ico file content.

  | 
| [the_embed_site_title()](https://developer.wordpress.org/reference/functions/the_embed_site_title/)`wp-includes/embed.php` |

Prints the necessary markup for the site title in an embed template.

  | 
| [wp_site_icon()](https://developer.wordpress.org/reference/functions/wp_site_icon/)`wp-includes/general-template.php` |

Displays site icon meta tags.

  | 
| [site_icon_url()](https://developer.wordpress.org/reference/functions/site_icon_url/)`wp-includes/general-template.php` |

Displays the Site Icon URL.

  | 
| [has_site_icon()](https://developer.wordpress.org/reference/functions/has_site_icon/)`wp-includes/general-template.php` |

Determines whether the site has a Site Icon.

  | 
| [atom_site_icon()](https://developer.wordpress.org/reference/functions/atom_site_icon/)`wp-includes/feed.php` |

Displays Site Icon in atom feeds.

  | 
| [rss2_site_icon()](https://developer.wordpress.org/reference/functions/rss2_site_icon/)`wp-includes/feed.php` |

Displays Site Icon in RSS2.

  | 
| [wp_admin_bar_site_menu()](https://developer.wordpress.org/reference/functions/wp_admin_bar_site_menu/)`wp-includes/admin-bar.php` |

Adds the “Site Name” menu.

  | 
| [wp_admin_bar_my_sites_menu()](https://developer.wordpress.org/reference/functions/wp_admin_bar_my_sites_menu/)`wp-includes/admin-bar.php` |

Adds the “My Sites/[Site Name]” menu and all submenus.

  |

[Show 5 more](https://developer.wordpress.org/reference/functions/get_site_icon_url/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_site_icon_url/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_site_icon_url/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.3.0](https://developer.wordpress.org/reference/since/4.3.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_site_icon_url%2F)
before being able to contribute a note or feedback.