/ Published in: PHP
I looked everywhere trying to find some code that could show me how to display the post thumbnail if there is an image, but to display absolutely nothing if there isn't an image to display (most just either added an image or there was a broken image if there was nothing to display).
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php if (get_post_meta($post->ID, 'post-image', true) != "" ) : ?> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="borderimg"> <?php $thumbnail_image = get_post_meta($post->ID, 'post-image', true);?> <img src="<?php bloginfo('template_url'); ?>/scripts/timthumb.php?src=<?php echo $thumbnail_image; ?>&h=141&w=200&zc=1" alt="" /> </a> <?php endif; ?>