Created
October 26, 2016 21:55
-
-
Save joviczarko/e1d07eab2aa84e4c5706fea4d9e2cb30 to your computer and use it in GitHub Desktop.
Page header with featured image as background in wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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