Return to Snippet

Revision: 27140
at May 24, 2010 20:18 by bdnnikki

Updated Code
<?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; ?>&amp;h=141&amp;w=200&amp;zc=1" alt="" />
<?php endif; ?>

Revision: 27139
at May 24, 2010 20:04 by bdnnikki

Initial Code
//this actually does the work without "adding post thumbnail"//
function get_post_thumbnail() {
$files = get_children('post_parent='.get_the_ID().'&post_type=attachment&post_mime_type=image');
if($files) :
$keys = array_reverse(array_keys($files));
$num = $keys[$j];
$image=wp_get_attachment_image($num, 'large', false);
$imagepieces = explode('"', $image);
$imagepath = $imagepieces[1];
echo "<div style='float: left; width: 175px; padding: 5px; margin-bottom: 15px;'><a href='";
echo "'/><img src='".$thumb."'/></div>";

Then, add this to where you want the post thumbnail to display

<?php get_post_thumbnail(); ?>

Initial URL

Initial Description
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).

Initial Title
Activating the Post Thumbnail feature in Wordpress but not showing anything if there is no image to display

Initial Tags
post, wordpress

Initial Language