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:

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

Find more details in the WordPress Codex:

About Jay Versluis

Jay is a medical miracle known as a Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

Add your voice!