1
votes

Is there a way to hide the featured image from SOME posts?

My blog is cur-mudg-eon.com and if you look at the most recent post (on the homepage) titled "Confucius Says..." you'll see that I've used the featured image and it shows some excerpt text. When you click on the title or pic it takes you to the post which shows the cartoon I wish to display, and the featured image that I want to hide/remove.

I only want to do this on some posts, but I would like to be able to keep the featured image on the homepage.

Is this possible?

EDIT:

Pastebin File as requested.

Based on Chris Herberts answer where would I add his code to this code found in my single.php file:

    <?php if(has_post_thumbnail()) {
        echo '<figure class="featured-thumbnail"><span class="img-wrap">'; the_post_thumbnail(); echo '</span></figure>';
        }
      ?>
    <?php } else { ?>
      <?php if(has_post_thumbnail()) {
        echo '<figure class="featured-thumbnail large"><span class="img-wrap"><span class="f-thumb-wrap">'; the_post_thumbnail('post-thumbnail-xl'); echo '</span></span></figure>';
        }
      ?>
    <?php } ?> 
2

2 Answers

8
votes

Another way to do this that does not depend on them all being in the same category is to use a Custom Field.

You would set a custom field for the post for which you would hide the featured image - in the image below I'm using "hide_featured_image" and "yes", as the key and value, respectively.

enter image description here

Then you would check to see if the "hide_featured_image" field is set to "yes" when calling calling the function to show the featured image. Here's an example:

$shouldHideFeaturedImage = get_post_meta($post->ID, 'hide_featured_image', true);

if ( $shouldHideFeaturedImage != 'yes' ) {
 if ( has_post_thumbnail() ) {
    the_post_thumbnail('medium'); 
    } 
}
2
votes

If all those posts are in the same categories, you can do something like this.

On your theme files, under the file single.php there should be something similar to this:

if ( has_post_thumbnail() ) {
the_post_thumbnail('medium'); 
} 

change it to something like:

if ( !in_category( array( 'category1', 'category2', 'etc' ) )) {
 if ( has_post_thumbnail() ) {
    the_post_thumbnail('medium'); 
    } 
}