Light bulb We updated the website and resources for you. Send Feedback

WP: Get Custom Logo Image URL for Built-in or Custom Sizes

Published 26 Nov, 2022 Modified 26 Nov, 2022 Read in 1m 20s Viewed 2.815K times

Get Wordpress custom logo image URL or source for custom sizes.


Experience Based


WordPress theme can provide a built-in option to set custom logo image from the Customizer.

WP has following built-in functions related to getting a custom logo:

  • the_custom_logo() – prints the logo with markup
  • get_custom_logo() – prints the logo with markup considering the parameters
  • has_custom_logo() – checks whether the custom logo is set or not

Unfortunately, none of the functions above return only the URL of the custom logo image. Developers might need the URL of custom logo added by user, therefore, we will directly get the URL from wp_get_attachment_image_src() function by padding custom logo id and the size of custom logo. If you don’t specify the size, it returns the URLs for all sizes of the custom logo.

By default, wp_get_attachment_image_src() returns array. We’ll use [0] to get the first required image.

$logo_original = wp_get_attachment_image_src(get_theme_mod('custom_logo'), 'full')[0]; 

We used get_theme_mod('custom_logo') function to get the ID of custom logo set via WordPress Customizer options.

To get custom logo in other available sizes, just replace 'full' with your custom image size such as thumbnail, medium, medium_large, large, and other registered custom image sizes.

Note: If the logo was set prior to the registration of custom sizes, then you need to remove and upload the logo again to let WP generate custom sizes for that logo image too.

$logo_other_size = wp_get_attachment_image_src(get_theme_mod('custom_logo'), 'thumbnail')[0]; 

$logo_custom_size = wp_get_attachment_image_src(get_theme_mod('custom_logo'), 'another-registered-size')[0];