How to Remove the Featured Image in Single Post from Wordpress?

User avatar
Posts: 2
Joined: Sat Sep 01, 2018 10:40 pm

How to Remove the Featured Image in Single Post from Wordpress?

Mon Nov 26, 2018 9:23 pm

In the default WordPress themes that come with every stock installation of WordPress, the featured image is displayed on both the homepage above every post entry as well as single post page.

Let's say for instance that we want to get rid of the display of the featured image in single pages only, but we want to retain it on the main homepage and other archives. This doesn't mean that we don't want to display the featured image in our posts at all. It just means that we want to be able to show it on our terms – perhaps within the post content itself if we like.

To achieve this goal of disabling the automatic placement of featured images within a single post, open up your functions.php file and paste in the following at the end before the closing "?>" PHP tag:
function my_post_image_html( $html, $post_id, $post_image_id ) {
if(is_single()) {
return '';
} else
return $html;
add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
However, if you don't want to add PHP code to WordPress, you can opt for the quick and dirty method of hiding via CSS.

This is a poor alternative to the first method because it doesn't actually prevent the featured image from being downloaded onto the page – it only hides it. This is a waste of resources not just on your server or CDN, but also for the user who is receiving content they will never view. But if for whatever reason you prefer to tackle this issue via CSS, inserting the following CSS code will hide ALL featured images added via the 'the_post_thumbnail' function:
.wp-post-image {
display: none !important;
Thanks. Guys