# Show the Featured Image Above Post Content

> Prints the featured image at the top of single posts, for themes that only use featured images on archive pages.

- Type: PHP
- Runs: Frontend only
- Category: [Content](https://wpide.com/library/category/content/)
- Tags: featured-image, posts, images
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/featured-image-above-content/

## Code

```php
// Image size to display.
$wpide_featured_size = 'large';

add_filter( 'the_content', function ( $content ) use ( $wpide_featured_size ) {
    if ( ! is_singular( 'post' ) || ! in_the_loop() || ! is_main_query() || ! has_post_thumbnail() ) {
        return $content;
    }

    $image   = get_the_post_thumbnail( null, $wpide_featured_size, array( 'loading' => 'eager', 'fetchpriority' => 'high' ) );
    $caption = get_the_post_thumbnail_caption();
    $caption = $caption ? '<figcaption>' . wp_kses_post( $caption ) . '</figcaption>' : '';

    return '<figure class="wpide-featured-image" style="margin:0 0 2em;">' . $image . $caption . '</figure>' . $content;
}, 5 );
```

## Notes

Change the image size from large to full or any registered size. Do not use it if your theme already shows the image on single posts.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Show the Featured Image Above Post Content" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
