How to set wordpress feature image as page or post header image

A featured image of wordpress represents the preface of post contents. It is also known as Post Thumbnail of wordpress.

How to add post thumbnail or featured image in WordPress

Featured Images or Post Thumbnails is a theme default feature. To add a featured image in a WordPress post, Simply create a new post and scroll down a little to see if there is a meta box called “Featured Image” on the right hand side of the screen. And click “Set feature image”.

This will open the WordPress media uploader to upload an image from your computer or use an existing image from your media library. Once you select the image, simply click on Set Featured Image button.

 

The image will appear in the Featured Image meta box, like this:

Voila!! you have successfully upload thumbnail into your WordPress post.

But if you want to add image in your WordPress post header, you will be needed a little bit of coding knowledge.

WordPress themes like Total or Enigma has white post header background. You can change header color very easily by changing its color in style.css.

But my real concern is to change header background by image.

Also read : How to hide your wordpress template name from others

First login to your WordPress admin panel and navigate to Appearance and then click on Editor.

** Please do this change in your Child Theme, so that you can avoid error.

Appearance → Editor

Find header.php or breadcrums.php, and edit any of these available file.

Search for your post header css class file and paste the below code

style=”background-image: url(<?php echo wp_get_attachment_url( get_post_thumbnail_id(get_the_ID()) );?>);” width=”100%”

After pasting the code update it. Then navigate to Pages or Posts. Now again upload a “Featured Image” on the right hand side of the screen. And save it as “Set feature image”.

We strongly recommend you to update header code or breadcrums code over child theme. If you don’t want to add image as header image then no need to edit header.php or breadcrums.php.