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

Facebook
Twitter
LinkedIn
Pinterest
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. Required fields are marked *

Want to speed up WordPress site?