Created
February 23, 2018 18:58
-
-
Save anwerashif/95417be7d839ef49a273c08a47332d3c to your computer and use it in GitHub Desktop.
Customize Single Post Featured Image and Add Before Entry
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
<?php | |
// Do NOT include the PHP opening tag | |
// Register a custom image size for Singular Featured images | |
add_image_size( 'singular-featured-thumb', 800, 450, true ); | |
// Display featured image before entry | |
add_action( 'genesis_before_entry', 'display_featured_image' ); | |
function display_featured_image() { | |
if ( ! is_singular( array( 'post' ) ) ) { | |
return; | |
} | |
if ( ! has_post_thumbnail() ) { | |
return; | |
} | |
// Display featured image above content | |
echo '<div class="singular-featured-image color-gradient">'; | |
genesis_image( array( 'size' => 'singular-featured-thumb' ) ); | |
echo '</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment