0


I have multiple posts in three categories.
The categories are
1. News
2. Images
3. Videos

If i click any post that Post's Feature image was shown in top of the article. But other two categories is ok but in Videos category i dont want to display feature images. Is there any way to do this..

(Note: I am setting feature images for videos category because i am using that image in different place. So i cant remove this. So tell some solution to hide image when viewing post)

0

I assume that all your posts are come from single.php. WordPress provides has_category() function to check if post has specific category.

So your code on single.php will need to be like something in given below

if( !has_category('video') ){
   the_post_thumbnail();
}

where it checks if post has 'video' category. And if it is false then the feature image will be displayed. otherwise, it can't. Hope it will be help you.

  • Thanks but i found other solution through css: .category-videos .post-image.single{display:none;} – Shriram Jun 6 '18 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.