Using WordPress ‘get_custom_logo()’ PHP function

The get_custom_logo() WordPress PHP function returns a custom logo, linked to the home page unless the theme supports removing the link on the home page.


echo get_custom_logo();


  • $blog_id (int): Optional. ID of the blog in question. Default is the ID of the current blog.

More information

See WordPress Developer Resources: get_custom_logo()

Related Functions:

  • the_custom_logo()
  • has_custom_logo()


Display the custom logo with a link to the home page.

echo get_custom_logo();

Get the custom logo URL

To get the URL of the custom logo image:

$custom_logo_id = get_theme_mod('custom_logo');
$image = wp_get_attachment_image_src($custom_logo_id, 'full');
echo $image[0];

Alternative method to get the custom logo URL

An alternative way to get the URL of the custom logo image:

echo esc_url(wp_get_attachment_url(get_theme_mod('custom_logo')));

Check if custom logo exists and display it

Check if the theme has a custom logo set, and if it does, display the custom logo.

if (has_custom_logo()) {
    echo get_custom_logo();
} else {
    // Display alternative content or logo

Display custom logo with custom markup

Display the custom logo with custom HTML markup.

$custom_logo_id = get_theme_mod('custom_logo');
$logo_url = wp_get_attachment_image_src($custom_logo_id, 'full')[0];
echo '<a href="' . esc_url(home_url('/')) . '" class="custom-logo-link"><img src="' . esc_url($logo_url) . '" alt="' . esc_attr(get_bloginfo('name')) . '"></a>';