Last active
December 12, 2016 22:55
-
-
Save cccamuseme/eae0646b5643d2499049d5081719d1d6 to your computer and use it in GitHub Desktop.
Use featured image as background image 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 $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?> | |
<div class="featured-image" style="background-image: url('<?php echo $thumb['0'];?>')"> | |
</div> | |
<style> | |
.featured-image { | |
width:100%; | |
height:400px; | |
background-size:cover; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment