Skip to content

Instantly share code, notes, and snippets.

@corilam
Created August 24, 2017 13:21
Show Gist options
  • Save corilam/b8aa8755d00a14548eb2c7dbde76b1bb to your computer and use it in GitHub Desktop.
Save corilam/b8aa8755d00a14548eb2c7dbde76b1bb to your computer and use it in GitHub Desktop.
Wordpress Background Image Using Featured Image
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'slideshow' );?>
<div style="background-image: url('<?php echo $thumb['0'];?>');" class="large-header-image">
</div>
@corilam
Copy link
Author

corilam commented Sep 17, 2017

Set up a background image using the WP Featured Image. This uses a custom size called 'slideshow', but change to fit the size you're working with. You'll also need to create a class, here called 'large-header-image' to display the area's height and width.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment