get_header_image()
Gets the URL of the header image, which is set in the theme settings.
Works only when the theme has the ability to set a header image.
Use header_image() when you need to output the URL to the screen, not to get it for processing.
Uses: get_theme_mod()
Used By: header_image()
Hooks from the function
Returns
String|false. An empty string will be returned if:
-
the current theme does not support a header image. How to enable such support can be read here: add_theme_support().
- a header image is not set for the current theme. It is set in the settings:
Appearance > Customize.
Usage
get_header_image();
Examples
#1 Display an img image tag for the header
<img src="<?php echo get_header_image(); ?>" alt="<?php bloginfo('title'); ?>">
Before using this, check out get_header_image_tag() first.
It will return an tag including the srcset attributes for responsive images.
#2 Display IMG tag using the_custom_header_markup()
the_custom_header_markup();
Can be use in place of:
<img alt="" src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" >
Changelog
| Since 2.1.0 | Introduced. |