-1

I have following setup:

//set defaults

$args = array(
        'default-image'          => get_template_directory_uri().'/images/banner.png',
        'random-default'         => false,
        'width'                  => 960,
        'height'                 => 100,
        'flex-height'            => true,
        'flex-width'             => true,
    );

//enable it

add_theme_support( 'custom-header', $args );

//use it

<img src="<?php header_image();?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="" />

But the src attribute of the image is empty string:

<img src="" height="100" width="960" alt="">

But if I hardcode the image src using

get_template_directory_uri().'/images/banner.png'

it works fine. I am not able to find the things I am missing. Thank you

1

As @Michael says, header_image() returns the URL, you need to echo it:

<img src="<?php echo esc_url( header_image() ) ?>" ...
  • Did exactly that, but still same result. – me_digvijay Jun 7 '15 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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