Last active
October 31, 2017 21:35
-
-
Save anwerashif/9f4652160a56bac999eb7a8ac224381e to your computer and use it in GitHub Desktop.
Add Featured Image to Single Post and Page in Genesis
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 | |
// Do NOT include the opening PHP tag | |
// Register a custom image size for Singular Post and Page Featured images | |
add_image_size( 'singular-featured-thumb', 880, 450, true ); // Hard Crop Mode | |
// Display featured image above content | |
add_action( 'genesis_before_entry', 'display_featured_image' ); | |
function display_featured_image() { | |
if ( ! is_singular( array( 'post', 'page' ) ) ) { | |
return; | |
} | |
if ( ! has_post_thumbnail() ) { | |
return; | |
} | |
// Array the image in class | |
echo '<div class="singular-featured-img mobile-hide">'; | |
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