How to test if a custom header image is used in WordPress

You can use a handy function named get_header_image() for this. It will return the image uploaded by a user, or an empty string if a custom header image is not used.

You can base decisions on this query:

if (get_header_image() == '') {
    // if no header image is present, do this
} else {
    // if we have a header image, do something else

Note that get_header_image() is not a boolean function, so testing like this won’t work:

if (get_header_image()) {
    // this is not going to work

Find more details in the WordPress Codex:

Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at and