Created
July 6, 2017 14:12
-
-
Save topleague/4ea187b24eb197dd3f7819621bbd90f0 to your computer and use it in GitHub Desktop.
Display Hero Image on Single Posts
This file contains hidden or 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
// Display Hero Image on Single Posts | |
// Credit: https://sridharkatakam.com/overlay-entry-title-featured-image-single-posts/ | |
add_action( 'genesis_after_header', 'topleague_hero_image' ); | |
function topleague_hero_image() { | |
if ( !is_singular( 'post' ) ) { // if we are not on a single Post, abort. | |
return; | |
} | |
if ( has_post_thumbnail() ) { | |
$image = genesis_get_image( 'format=url&size=post-image' ); // set $image to URL of featured image. | |
} ?> | |
<div class="post-hero" style="background-image: url('<?php echo $image; ?>')"> | |
</div> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment