How to Hide the Featured Image in a WordPress Post Without a Plugin

Last Updated on July 4, 2026

WordPress is the most popular content management system (CMS). It offers many user-friendly and SEO-friendly features. One of these features is the featured image, which is usually displayed next to the post title on blog and archive pages and at the top of the single post page.

Sometimes, the same image is used both as the featured image and inside the post content. This can make the image appear twice on the single post page, affecting the page layout and slightly increasing page load time.

In this tutorial, you’ll learn how to automatically hide the featured image without using a plugin whenever the post already contains an image. If you’re new to featured images, read our guide on What is a Featured Image in WordPress? to understand how they work.

Why Hide the Featured Image?

Hiding the featured image is useful in the following situations:

  • The same image is used as both the featured image and an image inside the post.
  • You want to avoid displaying duplicate images on the single post page.
  • You want to improve the page layout and reduce unnecessary content.
  • The image inside the post looks better or is a different size than the featured image.

This method checks whether the post content contains an image. If it does, the featured image is hidden automatically. If the post doesn’t contain any images, the featured image is displayed as usual.

Note: This solution only hides the featured image when the post content already contains at least one image.

Step 1: Log in to Your Hosting Account

Log in to your hosting control panel (cPanel) or connect to your website using an FTP client.

Step 2: Open Your Theme Folder

Navigate to your active theme folder:

wp-content/themes/your-theme/

Step 3: Locate the Single Post Template

Find the template file that displays single posts. In many WordPress themes, this file is:

template-parts/content-single.php

Your theme may use a different file, so search for the the_post_thumbnail() function if you cannot find this file.

Step 4: Find the Featured Image Code

Search for:

<?php
the_post_thumbnail( 'full', [ 'class' => 'class_name' ] );
?>

Step 5: Replace It with the Following Code

<?php
if ( has_post_thumbnail() ) {

$content = get_the_content();

// Check whether the post content contains an image.
if ( ! preg_match_all( '/<img[^>]+src=[\'"]([^\'"]+)[\'"]/i', $content, $matches ) ) {

the_post_thumbnail( 'full', [ 'class' => 'class_name' ] );

}
}
?>

The preg_match_all() function searches the post content for image tags. You can learn more about it in the official PHP documentation.

How the Code Works

  • Checks whether the post has a featured image.
  • Scans the post content for <img> tags.
  • If an image is found, the featured image is hidden.
  • If no image is found, the featured image is displayed normally.

Important: Replace class_name with the CSS class used by your theme. The template file location may also differ depending on your theme.

If you have any questions or run into any issues, feel free to leave a comment below. We’ll be happy to help.

Frequently Asked Questions

How do I hide the featured image in WordPress without a plugin?

You can hide the featured image by editing your theme’s content-single.php or single post template. Add a condition to display the featured image only when the post content does not contain any images.

Will this method remove the featured image from blog or archive pages?

No. This code only affects the single post page. The featured image will continue to appear on blog, category, archive, and search pages unless you modify those templates separately.

Do I need to install a WordPress plugin to hide the featured image?

No. This tutorial uses a simple PHP condition inside your theme, so no additional plugin is required.

Will the featured image be hidden for every post?

No. The featured image is hidden only if the post content already contains an image. If there are no images inside the post content, the featured image is displayed normally.

Which WordPress file should I edit?

Most themes use template-parts/content-single.php or single.php to display single posts. Search your active theme for the the_post_thumbnail() function to locate the correct file.

Does hiding the featured image improve website performance?

It can slightly improve page performance when the same image would otherwise be loaded twice. It also creates a cleaner layout by preventing duplicate images.

Related WordPress Tutorials

Stay updated with our latest news, special offers, and exclusive updates directly in your inbox.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Index
Scroll to Top
×