How to Add a Featured Image in WordPress Without a Plugin – 2024

Hey there, WordPress adventurers! You’re probably familiar with the concept of featured images, those handy visuals that accompany your posts and pages. Did you know you can add a featured image to your WordPress posts without a plugin? Well, grab your trusty coding quill, because we’re about to learn how to do just that! Let’s go!

Step 1: What’s a Featured Image?

A featured image, also known as a post thumbnail, is the main image used to represent a post, page, or custom post type. It’s a crucial element in web design and often appears on homepages, archives, and as previews when your posts are shared on social media.

Step 2: Enable Featured Image Support

Before we can start adding featured images, we need to make sure that our theme supports them. Add the following line of code to your theme’s functions.php file to enable featured image support:

				
					add_theme_support('post-thumbnails');

				
			

This line tells WordPress that your theme supports the use of featured images.

Step 3: Add a Featured Image to Your Post

With featured image support enabled, you can now add featured images to your posts. When you’re editing a post, you’ll see a new “Featured Image” box on the right side of your screen.

  1. Click on “Set featured image” in that box.
  2. Choose an image from your Media Library or upload a new one.
  3. Click on “Set featured image”.

Step 4: Display the Featured Image

To display the featured image in your post, you’ll need to add the following line of code to your single.php file or wherever you want the featured image to appear:

 
				
					the_post_thumbnail();

				
			

If you want to specify a size for the thumbnail, you can do that by adding a parameter to the function, like this:

				
					the_post_thumbnail('medium'); // display medium-size thumbnail

				
			

Or specify custom dimensions:

				
					the_post_thumbnail( array(200, 200) ); // display thumbnail with custom dimensions (200px by 200px)

				
			

And just like that, you’ve added a featured image to your WordPress post without a plugin. Now your posts will shine with visual awesomeness! Keep exploring, keep learning, and until next time, happy coding! 🚀

Table of Contents

Pro Feature

When to Use This Feature

Use Examples