Hide/remove featured images in particular categories post?

Issue

There are multiple posts in three categories.

The categories are

  1. News (Feedzy)
  2. Images
  3. Videos

If any post that Post’s Feature image was shown in top of the article. But other two categories is ok but in Videos category we don’t want to display feature images.

Note: we are setting feature images for videos category because we are using that image for archive posts. 

Solution

WordPress provides has_category() function to check if post has specific category.

There are 2 option to add your code

  1. Code on single.php (Need to create a child theme)
  2. PHP Raw widget (https://www.dynamic.ooo/widget/php-raw/)

The PHP will need to be like something in given below

				
					if( !has_category('videos') ){
   the_post_thumbnail('post-thumbnail', ['class' => 'op-post-featured-image', 'title' => 'Feature image']);
}

//if post has 'videos' category. And if it is false then the feature image will be displayed.
				
			

My easily option is code PHP directly in Theme Builder

Hope it will be help you 🙂