Skip to content

Instantly share code, notes, and snippets.

@anwerashif
Last active October 31, 2017 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anwerashif/9f4652160a56bac999eb7a8ac224381e to your computer and use it in GitHub Desktop.
Save anwerashif/9f4652160a56bac999eb7a8ac224381e to your computer and use it in GitHub Desktop.
Add Featured Image to Single Post and Page in Genesis
<?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