WordPress Thumbnails

Beginner
7 min read
Updated: Nov 2026
2 examples
Core concept

Definition

A thumbnail in WordPress is the featured image of a post. In the editor you set it in the Featured image box. In code it is called a post thumbnail.

Your theme shows it on blog lists, single posts, and cards. The usual pattern is to check with has_post_thumbnail(), then print it with the_post_thumbnail().

Three steps.

1) Enable it with add_theme_support( 'post-thumbnails' ). 2) Set the image in the post editor. 3) Check and print it in your template.

Syntax

Enable the feature once, then check and show the image.

WordPress
<?php
// functions.php
add_theme_support( 'post-thumbnails' );

// single.php
if ( has_post_thumbnail() ) {
  the_post_thumbnail( 'large' );
}

Which Function to Use

Four functions cover almost everything. The ones that start with get_ return a value. The others print.

FunctionPrints or returnsUse it to
has_post_thumbnail()Returns true or falseCheck if a post has a featured image
the_post_thumbnail()Prints the img tagShow the image quickly
get_the_post_thumbnail()Returns the img tagPut the image inside your own HTML
get_post_thumbnail_id()Returns the attachment IDUse with wp_get_attachment_image() or a custom URL

Always check with has_post_thumbnail() before you print any wrapper HTML. This avoids empty tags on posts that have no featured image.

Image Sizes

Pass a size to the_post_thumbnail() or get_the_post_thumbnail(). You can use a name or an array of width and height.

SizeWhat it means
'thumbnail'Small square image. Default 150 x 150, cropped. Set in Settings > Media.
'medium'Default max 300 x 300. Keeps the shape of the image.
'large'Default max 1024 x 1024. Keeps the shape of the image.
'full'The original image you uploaded.
'post-thumbnail'The theme's own size. A theme sets it with set_post_thumbnail_size(). This is the default.
array( 300, 200 )A custom width and height in pixels. WordPress picks the closest image size.
Theme size.

A theme sets its default size with set_post_thumbnail_size( 1200, 630, true ) in functions.php. That size is what 'post-thumbnail' means.

WordPress Examples

Two short examples with sample output.

Example 1 — Check, then show the image

Print the featured image only if the post has one.

WordPress
<?php if ( has_post_thumbnail() ) : ?>
  <div class="post-image">
    <?php the_post_thumbnail( 'medium' ); ?>
  </div>
<?php endif; ?>

How It Works

  1. has_post_thumbnail() returns true when a featured image is set.
  2. the_post_thumbnail( 'medium' ) prints the image at the medium size.
  3. If there is no image, the div is skipped.

Next: WordPress Thumbnail Functions

Now that you know the basics, open the functions index for all four guides.

Full list: WordPress Thumbnail Functions index (/wordpress/thumbnail/function).

Frequently Asked Questions

It is the featured image of a post. WordPress calls it a post thumbnail in code and a featured image in the editor.
Add add_theme_support( 'post-thumbnails' ) in your theme functions.php. Then the Featured image box shows in the post editor.
Check with has_post_thumbnail(), then print it with the_post_thumbnail().
the_post_thumbnail() prints the image. get_the_post_thumbnail() returns it as a string so you can wrap it in your own HTML.
thumbnail, medium, large, full, the theme size post-thumbnail, a custom size from add_image_size(), or an array of width and height.
Open the WordPress Thumbnail Functions index. It lists all four guides in short tables.

Browse every thumbnail function

Open the functions index for simple guides with examples and FAQs.

Thumbnail Functions Index →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful