How to add a header image in WP

by

Here is a quick example of how to add a background image to the header of your WordPress website pulling the Feature Image:

<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?>
<div id="page-sub-header" style="background: linear-gradient(rgba(0, 0, 0,0.6), rgba(0,0,0,0.6)), url('<?php echo $thumb['0'];?>');">
<div class="container">
<?php the_title( '<h1 class="entry-title white">', '</h1>' ); ?>
</div>
</div>

You could also use:

<div class="page-header" style="background-image:url(<?php echo (($feat_image[0]))?>);">

Leave a Reply

Your email address will not be published. Required fields are marked *


PageLines