Skip to content

Instantly share code, notes, and snippets.

@gagimilicevic
Created November 11, 2016 19:06
Show Gist options
  • Save gagimilicevic/c21792da2b212da35110cc15667b05ce to your computer and use it in GitHub Desktop.
Save gagimilicevic/c21792da2b212da35110cc15667b05ce to your computer and use it in GitHub Desktop.
Get featured image url and show it to page
<?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<div class="entry-header entry-header-background search-page-header" style="background-image: url('<?php echo $image[0]; ?>')">
<div class="container">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</div>
</div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment