• Resolved tom_taylor_85

    (@tom_taylor_85)


    Hey, I want to not display a thumbnail image or any thumbnail at all when I post under certain category…the thumbnail code I use is <td width="154"><a href="<?php the_permalink(); ?>"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" width="150" /></a></td>

    Is it possible to create an IF THEN function so that IF my post is under the category “video” THEN the thumbnail will not display?

    OR better yet, if I don’t add a thumbnail to the post, how can I get all that space???

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you want to simplify the custom field, you should probably try this:

    <?php
    $custom_thumb = get_post_meta($post->ID, "thumbnail", true);
    
    if($custom_thumb){ ?>
    <td width="154"><a href="<?php the_permalink(); ?>"><img src="<?php echo($custom_thumb); ?>" width="150" /></a></td>
    
    <?php } ?>

    That way, if there is not thumbnail defined, the entire td tag will be omitted. Remember, however, that such an omission will likely break the layout. If possible, you might want to make it eliminate the containing tr tags too, so it simply leaves out an entire row. I don’t know how your table is constructed so am not sure if you can get away with that.

    J

    Thread Starter tom_taylor_85

    (@tom_taylor_85)

    Thanks man, but I got it for now!!! I used this:

    <?php if(in_category(array('cat name','cat name')) ): ?>
    
    <td width="154"><a href="<?php the_permalink(); ?>"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" width="150" /></a></td>
    
    <?php endif; ?>

    So basically if it’s not in the following categories, it won’t display the thumbnail ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to not display a thumbnail for certain posts?’ is closed to new replies.