Issues displaying post images with custom fields
-
I’ve designed a blog index page that will display the five latest posts. Each post will include an image, post title, date/comments and an excerpt. So far, I have the following code, along with a custom field in each post with name=thumbnail and value= image path. The images displayed won’t appear in the posts, so they can be stand alone images that only appear on the blog index page.
<div class="post_wrap"> <h2 class="heading">Recent Posts</h2> <div style="border-bottom:1px dotted #C0C0C0; margin-bottom:10px; margin-left:14px; margin-right:14px; padding:0px 0px 10px 0px; clear:both;"></div> <div class="post_img"> <?php $recent = new WP_Query("cat=6&showposts=1"); while($recent->have_posts()) : $recent->the_post();?> <?php if( get_post_meta($post->ID, "Thumbnail", true) ): ?> <img style="float:left;margin:0px 5px 0px 0px;" src="<?php echo get_post_meta($post->ID, "Thumbnail", true); ?>" alt="alt text" /> <?php else: ?> <img style="float:left;margin:0px 5px 0px 0px;" src="<?php bloginfo('template_url'); ?>/images/thumbnail.jpg" alt ="Default Thumbnail" /> <?php endif; ?> </div><!--end post_img--> <div class="post_content"> <b><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></b> <div class="stamp"><?php the_time('F jS, Y') ?><!-- by <?php the_author() ?> --> | <?php comments_popup_link( 'No Comments »' , '1 Comment »', '% Comments »'); ?></div> <div class="excerpt"><?php if ($post->post_excerpt != "" ) {the_excerpt();}else {the_content_rss('', FALSE, '', 60);} ?><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> READ MORE</a> </div><!--end excerpt--> </div><!--end post_content--> <div style="border-bottom:1px dotted #C0C0C0; margin-bottom:10px; margin-left:14px; margin-right:14px; padding:0px 0px 10px 0px; clear:both;"></div> <?php endwhile; ?>
What am I doing wrong?
Viewing 14 replies - 1 through 14 (of 14 total)
Viewing 14 replies - 1 through 14 (of 14 total)
- The topic ‘Issues displaying post images with custom fields’ is closed to new replies.