How to Add Featured Image to Single Post

How to Add Featured Image to Single Post and Page in Genesis

wprocket

Place this piece of code in your theme’s functions.php to see the action.

// 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>';
}

After implementation of this code snippet you’ll be need to resize featured image, use Regenerate Thumbnails plugin.

 

GenesisPro728x90

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest
Share on tumblr
Tumblr
Anwer Ashif

Anwer Ashif

Founder of RainaStudio. Help businesses and individuals to create and outstand their online presence. Our success rate is measurable. Our blog served all around the world and counting.

Leave a Reply

Your email address will not be published.

Want to speed up WordPress site?