How to display a post’s Featured Image with this code?

Modify your function as such:

// This theme displays custom size (page-single) featured image on the Post's page
function InsertFeaturedImage($content) {

    global $post;

    $original_content = $content;

    if ( current_theme_supports( 'post-thumbnails' ) ) {

         if ((is_page()) || (is_single())) {

            $content = get_the_image( array( 'size' => 'full' ) );
            $content .= $original_content;

         }

    }

    return $content;

}

add_filter( 'the_content', 'InsertFeaturedImage' );

In the code, 'size' => 'full' defines the image size to be shown. You can choose between thumbnail, medium, large, full, or any custom image size that your theme uses (none in your theme). The default is thumbnail.

UPDATE: Answer last edited based on comment.

Leave a Comment