WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I thought there was a conditional for a custom image header that could check whether an image had been added (not whether the feature was enabled, but actually being used). I wanted to use it to add a body class, but I can't find it again. Does anyone know of how to check if the site has a custom header?

share|improve this question
up vote 1 down vote accepted

you could try the following right before you call the body_class() function:

$header_image = get_header_image();
if( !empty( $header_image) ){
    $custom_body_class = 'has-header-image';
} else {
    $custom_body_class = 'no-header-image';
<body <?php body_class($custom_body_class); ?>>
share|improve this answer
Beautiful! Thanks very much. – Christopher Jan 25 '13 at 16:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.