Forums

Disabling thumbnails from certain categories (8 posts)

  1. 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

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    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.

  3. 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

  4. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    <?php
    // don't show thumbnail for categories 3, 7 & 9
    if( !is_category( array(3,7,'9') ) ) the_post_thumbnail();
    ?>
  5. 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

  6. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    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.

  7. fabiovasques
    Member
    Posted 1 year ago #

    Thanks! In which file should I insert this code?

    Thanks in advance
    Fábio

  8. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    In your theme's category template file. Either category.php. archive.php or index.php - depending upon the theme.

Topic Closed

This topic has been closed to new replies.

About this Topic