has_custom_logo()WP 4.5.0

Determines whether the site has a custom logo.

1 time — 0.000037 sec (very fast) | 50000 times — 0.59 sec (very fast) | PHP 7.0.5, WP 4.5

No Hooks.

Return

true|false. Whether the site has a custom logo or not.

Usage

has_custom_logo( $blog_id );
$blog_id(int)
ID of the blog in question.
Default: ID of the current blog

Examples

0

#1 Check if the logo is specified for the site

if( has_custom_logo() ){
	// we have a logo, display it
	echo get_custom_logo();
}
0

#2 Using get_custom_logo()

To check if the logo is specified for the site. You can use get_custom_logo().

This example don't check multisite and don't do site-switching:

if( $logo = get_custom_logo() ){
	echo $logo;
}

See Also:

Changelog

Since 4.5.0 Introduced.

Code of has_custom_logo() WP 5.9.3

function has_custom_logo( $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;
	}

	$custom_logo_id = get_theme_mod( 'custom_logo' );

	if ( $switched_blog ) {
		restore_current_blog();
	}

	return (bool) $custom_logo_id;
}