get_header_image() WordPress Function

The get_header_image() function allows you to retrieve the URL of the header image set for the current theme. This can be useful if you want to use the header image in a custom location or for further customization.

get_header_image() #

Retrieves header image for custom header.


Return

(string|false)


Top ↑

Source

File: wp-includes/theme.php

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();
	}

	return esc_url_raw( set_url_scheme( $url ) );
}


Top ↑

Changelog

Changelog
VersionDescription
2.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More