Custom Header is a Theme feature though which WordPress Header Image can be changed easily from the Appearance > Header section. Most of the time the header image is used as a website logo, therefore it becomes important that theme developers should enable this feature in their theme.
To enable Custom Header add the below code in your theme’s functions.php file –
/*Custom header*/ $args = array( 'width' => 300, 'height' => 150, 'default-image' => get_template_directory_uri() . '/Images/logo.png', ); add_theme_support( 'custom-header', $args ); /*End*/
Explanation – In the above code I have enabled the Custom Header feature and provided the width, height and also the default image location to the header image.
Open your theme’s header.php file and add the below code to where you want the custom header to show.
<img src="<?php header_image(); ?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="custom header" />
Now the site owners can upload the image from the Appearance > Header section and can use it for changing their website logo.