I'm trying to set a default image to a Customizer image with the code below but image does not display.

<img src="<?php echo get_theme_mod( 'header_image' , '<?php get_template_directory_uri(); ?>/images/default-image.jpg' ); ?>">

Am I missing something?


Can you try this if it will work.

<img src="<?php echo get_theme_mod( 'header_image' , get_template_directory_uri().'/images/default-image.jpg' ); ?>">
  • Actually, you should use header_image(). This will then automatically return the default-image as supplied when defining the custom-header theme support. So this can be as simple as: <img src="<?php header_image(); ?>">. But then you should yet again consider using the_header_image_tag() for that, but then yet again, as of 4.7 you should use the_custom_header_markup(). Nov 25 '16 at 8:40

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.