HTTP/2 301
server: nginx
date: Tue, 30 Dec 2025 04:49:07 GMT
content-type: text/html; charset=UTF-8
location: https://developer.wordpress.org/reference/functions/get_header_image/
x-content-type-options: nosniff
content-language: en
x-ua-compatible: IE=Edge
vary: Accept-Encoding, Cookie
expires: Thu, 01 Jan 1970 00:00:00 GMT
cache-control: no-cache, no-store, max-age=0, must-revalidate
pragma: no-cache
alt-svc: h3=":443"; ma=86400
strict-transport-security: max-age=31536000
HTTP/2 200
server: nginx
date: Tue, 30 Dec 2025 04:49:09 GMT
content-type: text/html; charset=UTF-8
vary: Accept-Encoding
x-olaf: ⛄
vary: accept, content-type
link:
; rel="https://api.w.org/"
link:
; rel="alternate"; title="JSON"; type="application/json"
link: ; rel=shortlink
x-frame-options: SAMEORIGIN
content-encoding: gzip
alt-svc: h3=":443"; ma=86400
x-nc: MISS ord 1
get_header_image() – Function | Developer.WordPress.org
get_header_image(): string|false
Retrieves header image for custom header.
function get_header_image() {
$url = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );
if ( 'remove-header' === $url ) {
return false;
}
if ( is_random_header_image() ) {
$url = get_random_header_image();
}
/**
* Filters the header image URL.
*
* @since 6.1.0
*
* @param string $url Header image URL.
*/
$url = apply_filters( 'get_header_image', $url );
if ( ! is_string( $url ) ) {
return false;
}
$url = trim( $url );
return sanitize_url( set_url_scheme( $url ) );
}
View all references View on Trac View on GitHub
Version Description 2.1.0 Introduced.
Before using this, check out get_header_image_tag() first. That’s a new function in 4.4 that’ll return an tag including the srcset attributes for responsive images.
https://developer.wordpress.org/reference/functions/get_header_image_tag/
can be use in place of
[html]
<img alt="" src="<?php header_image() ; ?>" width="<?php echo get_custom_header() ->width; ?>" height="<?php echo get_custom_header() ->height; ?>">[/html]
Related:
header_image
has_header_image
Example