How to Add Post Thumbnails to Any WordPress Theme (2026)
Want to add post thumbnails to a WordPress theme, so each post shows its featured image on your homepage and archives? Almost every modern theme supports featured images out of the box, but older or custom themes may need a few lines of code. We added post thumbnails to our own custom theme in 2012 this way, and the same WordPress functions still work in 2026, with a few improvements.
![]()
Quick answer: To add post thumbnails to a WordPress theme, enable support in functions.php with add_theme_support( 'post-thumbnails' ); inside an after_setup_theme hook. Then show the image in your templates with the_post_thumbnail( 'medium' ); inside an if ( has_post_thumbnail() ) check. Block themes don’t need code: add the Post Featured Image block in the Site Editor.
Table of Contents
Step 1: Set a featured image on your posts
Post thumbnails display each post’s featured image. In the Classic Editor, use the Featured image box in the right sidebar and click Set featured image. In the block editor, open the Post settings panel and choose Featured image. Need to add images to many old posts? See how to add featured images to multiple posts quickly.
Step 2: Add post thumbnails support to your theme
Add this to your child theme’s functions.php file:
function qot_theme_setup() {
add_theme_support( 'post-thumbnails' );
add_image_size( 'qot-card', 400, 225, true ); // optional custom size
}
add_action( 'after_setup_theme', 'qot_theme_setup' );Using the after_setup_theme hook is the recommended way. The optional add_image_size() line creates a cropped 400×225 size for new uploads; use a plugin like Regenerate Thumbnails to create it for older images.
Tip: in a file that contains only PHP, leave out the closing ?> tag. Extra blank lines after it can cause “headers already sent” and feed XML errors. Always keep a backup, because a mistake in functions.php can take your site down until you fix it over FTP or your host’s file manager.
Step 3: Display post thumbnails in your templates
In index.php, archive.php or a template part such as content.php, add this inside the loop, above the title or excerpt:
<?php if ( has_post_thumbnail() ) : ?>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail( 'medium', array( 'loading' => 'lazy' ) ); ?>
</a>
<?php endif; ?>You can use any registered size: 'thumbnail' (150×150 by default), 'medium', 'large', 'full' or your own size such as 'qot-card'. WordPress automatically adds srcset so browsers load the right size for each screen, plus width and height to prevent layout shift. Lazy loading keeps archive pages fast; learn more in our guide to lazy loading images.
Step 4: Style post thumbnails with CSS
WordPress adds the class wp-post-image to every post thumbnail. A simple, responsive style:
img.wp-post-image {
max-width: 100%;
height: auto;
border-radius: 8px;
margin-bottom: 1rem;
}For a list layout with the image beside the text, float it or use CSS grid on wider screens only, so thumbnails stack neatly on phones.
Post thumbnails in block themes
In block themes such as Twenty Twenty-Five, go to Appearance > Editor > Templates, open the Blog Home or Archive template, select the Query Loop block and add a Post Featured Image block. You can set its aspect ratio, size and whether it links to the post, all without code.
Frequently asked questions
Why are my post thumbnails not showing?
Either the theme doesn’t support them, the post has no featured image, or the template doesn’t call the_post_thumbnail(). Check all three.
What size should WordPress post thumbnails be?
Upload featured images at least 1200 pixels wide (1200×630 is also ideal for social sharing). WordPress creates smaller sizes automatically.
What’s the difference between a post thumbnail and a featured image?
They’re the same thing. “Post thumbnail” is the developer term; “featured image” is the label in the editor.
Can I add a default thumbnail for posts without images?
Yes. Add an else branch that shows a placeholder image, or use a plugin that sets a default featured image.
Get our free weekly email: new tech guides and tools, no spam.
New and updated tech guides, a free tool worth bookmarking and one useful pick, once a week. No spam, unsubscribe anytime.
One email a week. Unsubscribe anytime. See our privacy policy.







Whats wrong if i use some Plugin for the same, will it affect my Rankings in Search Engines ?
Its best to use simple code than continue to use plugins for every small feature. Images increase visitor experience and helps improve your site engagement parameters.
Do you have something like this for blogger? I need something like this. Please share if you have. Thank you.
That’s a very useful article. I’ve been using WordPress plugin to add thumbnails. Will use this manual method so that I can reduce some burden on the server. Thanks.