How to add a thumbnail to a custom WordPress theme?

We continue our series of articles on how to build a custom WordPress theme. In this article, we are going to talk about how to add thumbnail support to our custom WordPress theme.

Unlock the Full Potential of WordPress Today! 🚀

Are you tired of struggling with WordPress? Ready to become a confident, skilled WordPress user?

Don’t miss this comprehensive course by renowned expert Nat Miletic! 🔥

What you’ll gain:

✅ A solid understanding of WordPress fundamentals
✅ Step-by-step guidance on hosting setup and installation
✅ Mastery over plugins, console, themes, and WooCommerce
✅ Proven SEO strategies to boost your site’s visibility
✅ Expert techniques for fine-tuning performance

🎯 Transform your WordPress experience and create stunning websites with ease. Join hundreds of satisfied learners and take your skills to the next level! 👉 Click here to enroll in the Ultimate WordPress Course by Nat Miletic now!


In this series of articles, we are using a FREE HTML template by Nathan.

In order to add thumbnails to a custom WordPress theme, we need to add support for it in functions.php. We already did the same thing for the logo. And it is really simple.

function theme_add_thumbnail_support() {
    add_theme_support( 'post-thumbnails' );

add_action( 'after_setup_theme', 'theme_add_thumbnail_support' );

Now, we can add thumbnails to our posts, pages, and other content types. If we want to restrict what post types thumbnails could be attached, we can provide the second parameter to add_theme_support() function. The second would be an array of post type(s).

function theme_add_thumbnail_support() {
     * Add thumbnails only to post and page post type
     * */
    add_theme_support( 'post-thumbnails', array('post', 'page') );

add_action( 'after_setup_theme', 'theme_add_thumbnail_support' );

As we can see in the code snippet above, thumbnails could only be added to Posts and Pages. Not on other post types.

If you have any questions or anything you can find me on my Twitter, or you can read some of my other articles like JavaScript Object Keys.