Skip to content

Instantly share code, notes, and snippets.

@anwerashif
Created February 23, 2018 18:58
Show Gist options
  • Save anwerashif/95417be7d839ef49a273c08a47332d3c to your computer and use it in GitHub Desktop.
Save anwerashif/95417be7d839ef49a273c08a47332d3c to your computer and use it in GitHub Desktop.
Customize Single Post Featured Image and Add Before Entry
<?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