Skip to content

Instantly share code, notes, and snippets.

@joviczarko
Created October 26, 2016 21:55
Show Gist options
  • Save joviczarko/e1d07eab2aa84e4c5706fea4d9e2cb30 to your computer and use it in GitHub Desktop.
Save joviczarko/e1d07eab2aa84e4c5706fea4d9e2cb30 to your computer and use it in GitHub Desktop.
Page header with featured image as background in wordpress
<?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<header class="entry-header entry-header-background" style="background-image: url('<?php echo $image[0]; ?>')">
<?php else: ?>
<header class="entry-header">
<?php endif; ?>
<div class="container">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</div>
</header><!-- .entry-header -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment