Tuesday, May 27, 2025

3 min read

How to Add a Featured Image in WordPress Without a Plugin

Featured images, also known as post thumbnails, are an essential part of modern WordPress design. They give your posts a visual identity and make your blog or news pages look more engaging. Luckily, you can enable and use them without any plugins – just a few lines of code in your theme files.

A featured image represents a post, page, or custom post type. It usually appears on archive pages, homepages, and in social shares. Think of it as the 'cover photo' for each piece of content on your site.

First, make sure your theme supports featured images. Add the following code to your theme’s `functions.php` file:

php
add_theme_support( 'post-thumbnails' );

This tells WordPress that your theme supports post thumbnails. Once added, a 'Featured Image' box will appear in the editor for posts and pages.

Step 3: Add a Featured Image to a Post

Now that featured images are enabled, you can set one from the WordPress editor:

  1. Open any post or page in the WordPress editor.
  2. Locate the “Featured Image” box in the sidebar.
  3. Click “Set featured image.”
  4. Select or upload your image, then click “Set featured image.”

That’s it! Your post now has a featured image assigned to it. If it’s not visible on the front end yet, you’ll need to display it in your theme template next.

To display the featured image in your theme, open your `single.php`, `content.php`, or whichever template displays post content, and add this line inside the WordPress Loop:

php
<?php the_post_thumbnail(); ?>

By default, this outputs the featured image at the 'post-thumbnail' size. You can specify other sizes or define custom dimensions if needed:

php
<?php the_post_thumbnail( 'medium' ); // Use the medium image size ?>
php
<?php the_post_thumbnail( array(200, 200) ); // Custom dimensions ?>

You can also wrap this in a conditional check to only show it if one exists:

php
<?php
  if ( has_post_thumbnail() ) {
      the_post_thumbnail( 'large' );
  }
  ?>

Optional: Register Custom Image Sizes

You can define your own image sizes for use with featured images. Add this to your `functions.php` file:

php
add_image_size( 'custom-thumb', 400, 250, true ); // Cropped thumbnail

Then call it like this wherever you want to display it:

php
<?php the_post_thumbnail( 'custom-thumb' ); ?>

WordPress Developer Reference – the_post_thumbnail():

WordPress add_theme_support() documentation:

That’s all there is to it! By enabling and displaying featured images manually, you get clean control over your post layouts without relying on plugins. Whether you’re customizing your theme or building one from scratch, this method keeps things lightweight and efficient.

About the Author
Jonas Lindemann

I’m an experienced SEO professional with over a decade of helping over 100 businesses rank higher online, especially local businesses, e-commerce stores and SaaS. As the co-founder of LPagery, I specialize in practical, proven strategies for regular SEO and Local SEO success.