Tutorial – How To Change WordPress Header Image?

Tutorial – How To Change WordPress Header Image?

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.

Now you don’t have to move to any other email marketing service because WordPress Subscription Plugin can help you to create and send powerful newsletters to your customer’s email addresses.

Enabling WordPress Custom Header

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.

A related tutorial which you should also read is – How To Change WordPress Background Image?

Showing WordPress Custom Header

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.

Changing Custom Header Image

Changing Custom Header Image

If you have a requirement for a specific post, then you can fulfill it by creatingWordPress Custom Post Type.

Share this article -

yogihosting

ABOUT THE AUTHOR

This article has been written by the Technical Staff of YogiHosting. Check out other articles on "WordPress, SEO, jQuery, HTML" and more.