views:

6

answers:

0

I'm trying to add thumbnail images (from the first post attachment found for each post) to my categories page (archive.php).

I've ensured that my posts all have images attached (confirmed via the Media Manager), however, I can't get the images to appear.

I only want to list a single thumbnail image next to each post listing on the category page, regardless how many attachments are there, but at present, I can't get a single image thumbnail to appear.

Here's the code I'm using in archive.php...

    <?php while (have_posts()) : the_post(); ?>
    <?php $images=get_children( array('post_parent'=>$post->ID,'post_mime_type'=>'image','numberposts'=>1));?>
        <div class="searchItem" style="clear:both;">
            <h3 id="post-<?php the_ID(); ?>"><?php echo wp_get_attachment_image($images[0]->ID, 'large'); ?><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
            <small><?php the_time('l, F jS, Y') ?></small>
            <div class="excerpt"><?php echo $post->post_excerpt; ?></div>
            <div class="postmetadata">Posted in <?php the_category(', ') ?> | <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></div>
        </div>
    <?php endwhile; ?>