fabiovasques
Member
Posted 1 year ago #
Hello,
In my blog the thumbnail feature is enabled. However, I would like that this feature was enabled only to certain categories. Eg.: I have two categories, in which the posts associate to them go to the home page - to these categories I want the thumbnails enabled. However, I have other posts associate to other categories, which don't go the home page - to posts from these categories, I would like do disable the thumbnail feature. Is this possible?
Thanks in advance,
Fábio Vasques
You can't disable post thumbnails on a per-category basis but you could stop any post thumbnails from being displayed for certain categories using the is_category conditional.
fabiovasques
Member
Posted 1 year ago #
Hi,
Thanks for your quick response!
Could you please be more specific? I'm not very familiar with PHP...just know how to change the basic...
Thanks again!
Fábio
<?php
// don't show thumbnail for categories 3, 7 & 9
if( !is_category( array(3,7,'9') ) ) the_post_thumbnail();
?>
fabiovasques
Member
Posted 1 year ago #
Thanks for the code! I understood that I have to adapt it to my categories. In your example, the last category (9) is between '', right?
Only one last help: in which file do I insert it?
I tried in a few files, but didn't work. Eg.: When I've inserted the code in the "post-thumb.php" file, didn't work to the selected categories (thumbnails were still showing) and in the non-selected categories the thumbnail got bigger.
Thanks again for your help and your patience!
Fábio
Typo. It should have read:
<?php
// don't show thumbnail for categories 3, 7 & 9
if( !is_category( array(3,7,9) ) ) the_post_thumbnail();
?>
No single quotes.
fabiovasques
Member
Posted 1 year ago #
Thanks! In which file should I insert this code?
Thanks in advance
Fábio
In your theme's category template file. Either category.php. archive.php or index.php - depending upon the theme.