
🖼 How to add thumbnail support to a WordPress theme
Developing your own WordPress theme and the "Featured image" block is missing from the editor? Standard themes like Twenty Twenty-Four show it right after activation. A custom theme written from scratch, however, won't show this block, and that's not a bug.
Two lines of code in functions.php, and the Featured image block with the Set featured image button appears in the editor sidebar. Let's walk through the whole mechanism: why WordPress requires manual feature registration, where exactly to insert the code, and how to output the featured image on the front end.
💡 Quick overview:
- What add_theme_support is and why a custom theme doesn't see featured images
- Code to enable featured image support: 2 lines on the after_setup_theme hook
- Checking the result in the admin and common reasons the block didn't appear
- Outputting the featured image on site pages via the_post_thumbnail()
- Full list of theme features that require manual registration
Why the "Featured image" block is missing from the theme
WordPress supports featured images out of the box, but not for every theme. Standard themes from the directory include this capability by default. A custom theme built by a developer from scratch must explicitly declare featured image support.
The reason lies in the add_theme_support() mechanism. WordPress doesn't blindly enable every feature: a theme must register certain capabilities itself. This applies not only to featured images but also to custom logos, HTML5 markup, widgets, RSS feeds, and two dozen other features. The approach gives the developer full control: the theme pulls in nothing it doesn't need.
Without calling add_theme_support('post-thumbnails'), WordPress simply doesn't know your theme is ready to work with featured images. The admin interface doesn't appear, and the has_post_thumbnail() function returns false. Fortunately, this is fixed with a couple of lines.
Step 1: Add featured image support in functions.php
The code consists of two elements: registering featured image support and hooking it to after_setup_theme. Open your theme's functions.php (or your child theme's, if you don't want to touch the parent) and add the snippet below.
1 /** 2 * Register support for post thumbnails for the theme. 3 */ 4 function mytheme_register_post_thumbnails() { 5 add_theme_support( 'post-thumbnails' ); 6 } 7 add_action( 'after_setup_theme', 'mytheme_register_post_thumbnails' );
The add_theme_support('post-thumbnails') function tells WordPress: this theme can work with featured images. The call is wrapped in the after_setup_theme hook: it fires after the theme is initialized, but before the init hook. The official WordPress documentation explicitly states: the call must happen before init, otherwise registration won't work for some features.
The after_setup_theme hook is the standard place for ALL add_theme_support calls. If your theme already has this hook, add the add_theme_support('post-thumbnails') line inside the existing function instead of creating a new one.
Optional: featured images only for specific post types. If you need images only for blog posts, for example, pass an array of post types as the second argument:
1 // Thumbnails only for posts, but not for pages. 2 add_theme_support( 'post-thumbnails', array( 'post' ) );
Options: array('post') for posts only; array('page') for pages only; array('post', 'page') for both. For custom post types, featured image support is enabled separately via the supports parameter in register_post_type().
Step 2: Check the result in the admin
After adding the code, open the editor for any post: Posts → Add New or Posts → edit an existing one. The Featured image block with the Set featured image button should appear in the right sidebar.
If the block didn't appear, check three things in order. The file is named exactly functions.php, not function.php, one missing letter s, and WordPress silently ignores the file. The code is added to the active theme: the one selected in Appearance → Themes, not some other theme. Third: in the editor's Screen Options (the tab at the very top of the page), the "Featured image" checkbox is enabled, sometimes it's unchecked by default.
Step 3: Outputting the featured image on the front end
Registering support adds the admin interface, but doesn't automatically display the image on the site. To show the featured image in the template, add a the_post_thumbnail() call to your theme files.
1 if ( has_post_thumbnail() ) { 2 the_post_thumbnail( 'large' ); 3 }
The has_post_thumbnail() function is a check: if a featured image is assigned to the post, we output it. Without it, posts without an image will leave an empty space (or a broken <img>).
The 'large' parameter sets the size. Standard WordPress options: 'thumbnail' (150×150), 'medium' (300×300), 'large' (1024×1024), 'full' (original). Read more about sizes in the WordPress image documentation. A custom size is registered via add_image_size('hero', 1200, 630, true) in functions.php, after which it's available by the slug 'hero'.
Where to insert. Usually the_post_thumbnail() is placed in single.php (single post page), index.php (blog post list), or archive.php (archives). The spot, right after the opening <article> tag or before the heading, depends on the layout. For a post list, use 'medium' instead of 'large': the image is smaller, and the page loads faster.
Full list: which other theme features need manual registration
Featured images are just one of roughly two dozen capabilities a custom theme must explicitly declare. Here are the main features registered via add_theme_support():
Feature | What it provides |
|---|---|
|
|
| Automatic RSS feed links in |
| HTML5 markup for search forms, comments, and galleries |
| Custom logo upload via the Customizer |
| Custom header: image or color |
| Custom page background |
| Widget support in sidebar and footer |
| Post formats: aside, gallery, quote, video |
| Enqueue styles for the Gutenberg block editor |
| Responsive embedding of video and other embed content |
| Wide and full-width block alignment in Gutenberg |
| Base styles for editor blocks |
| Dark theme support in the editor |
| Custom color palette in the editor |
For the full list and current feature names, see the official WordPress documentation. A good practice for a new theme: collect ALL necessary add_theme_support calls in a single setup function on the after_setup_theme hook. One glance at such a block is enough to understand which capabilities the theme supports, and you won't forget anything during further development.
📺 Video: Complete guide to WordPress featured images
A visual walkthrough of the topic, from code installation to size configuration, in the video below.
⁉️🤔 Frequently asked questions
Can I enable featured images via a plugin instead of functions.php?
Yes. The same code on the after_setup_theme hook works from a plugin. Install Code Snippets, add the fragment, and featured image support will be enabled without editing theme files. This method is convenient if you don't want changes to be lost on the next theme update.
Yes, the same code fragment works in both a theme and a plugin. Via Code Snippets, you add exactly the same two lines with
add_theme_support('post-thumbnails')on theafter_setup_themehook. After activating the snippet, the Featured image block appears in the editor within a minute. Changes aren't overwritten on theme updates, that's the main advantage of the plugin approach.
What if the Featured image block didn't appear after adding the code?
Check three common causes. First: the file name is functions.php (not function.php). A one-letter typo, and WordPress silently ignores the file. Second: the code ended up in an inactive theme. Third: the Featured image checkbox is unchecked in the post editor's Screen Options. In most cases, the problem lies in one of these three points.
The three most common causes, in order of likelihood: a typo in the file name (
function.phpinstead offunctions.php), the code was added to the wrong theme (check Appearance → Themes), or the Featured image checkbox is unchecked in the editor's Screen Options. Each takes half a minute to check. If all three are fine but the block is still not visible, clear your browser cache or open the editor in incognito mode.
Is the after_setup_theme hook mandatory?
The official WordPress documentation requires add_theme_support to be called before the init hook. A direct call in the body of functions.php without a hook technically works, because the functions.php file loads before init. But using after_setup_theme is the standard followed by all quality themes. The reason isn't just discipline: child themes load their functions.php before the parent's, and placing ALL feature registrations in one hook guarantees a predictable execution order.
Technically, no. A direct call in the body of
functions.phpworks because the file loads beforeinit. Butafter_setup_themeis the industry standard. Child themes load theirfunctions.phpbefore the parent's, and collecting alladd_theme_supportregistrations in one hook gives a predictable execution order. This is especially important when a child theme overrides or supplements the parent's settings.
How do I output a featured image at a specific, non-standard size?
Register a custom size via add_image_size('hero', 1200, 630, true) in functions.php, then call the_post_thumbnail('hero') in the template. The fourth parameter true means hard crop: WordPress will crop the image exactly to the specified dimensions, rather than just fitting it within a box. After adding add_image_size, install the Regenerate Thumbnails plugin and regenerate thumbnails; otherwise the new size will only be available for images uploaded after registration.
First, register the size via
add_image_size('hero', 1200, 630, true)infunctions.php. The fourth parametertrueenables a hard crop to the pixel. Then callthe_post_thumbnail('hero'). Important: after registering a new size, run Regenerate Thumbnails, without this, old images won't get the custom size, and WordPress will serve the nearest suitable one or the original.
Is adding only add_theme_support('post-thumbnails') enough for a modern theme?
No. post-thumbnails only enables the featured image upload interface in the admin and basic output functions. A full-fledged modern theme should register at least five features: title-tag (<title> management), automatic-feed-links (RSS), html5 (valid markup for forms and comments), responsive-embeds (responsive video), and wp-block-styles (Gutenberg block styles). Without title-tag, for example, SEO plugins can't manage the page title in search results.
No, that single line is not enough.
post-thumbnailsis just one of the mandatory registrations. The minimum set for a modern theme includes five features: title-tag, automatic-feed-links, html5, responsive-embeds, and wp-block-styles. Without title-tag, SEO plugins lose control over the<title>tag; without html5, search forms and comments render with outdated markup; and without responsive-embeds, embedded videos don't adapt to mobile screens.
What to do if featured image support isn't working: final checklist
Two lines of code on the after_setup_theme hook, and the featured image block appears in the editor. If not, go through the three points from Step 2: file name, active theme, Screen Options. As a rule, the problem is solved on the very first point.
To display the image on the site, don't forget the_post_thumbnail() in your templates. And while you're at it, check which other features your theme isn't registering, the table above will help you close all the gaps in one go.
Start with the critical minimum: title-tag for SEO, automatic-feed-links for RSS, html5 for valid markup, responsive-embeds for responsive video on mobile. Collect them in the same after_setup_theme function where post-thumbnails already lives, and your theme will immediately be several steps closer to WordPress quality standards.


