I am trying to create a second loop on my homepage that contains an image thumnail and headline for the post. Here is my code:
<div id="images_box_thumbs">
<div class="sidebar_title">Featured Posts</div>
<?php $query = new WP_Query('category_name=featured&showposts=6'); ?>
<?php while ($query->have_posts()) : $query->the_post(); ?>
<div id="images_box"><!-- Category Image Posts -->
<a title="Permanent Link to <?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"> <a href="<?php the_permalink() ?>" rel="bookmark"> <?php
$files = get_children("post_parent=$id&post_type=attachment&post_mime_type=image");
if($files){
$keys = array_keys($files);
$num=$keys[0];
$thumb=wp_get_attachment_thumb_url($num);
print "<div class='photo_thumb'><a href='".get_permalink()."' title=''><img src='$thumb' class='thumbnail' alt='' /></a></div>";
}
?></a><br />
<a class="gal_link" title="Permanent Link to <?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
<a class="gal_read_more" title="Permanent Link to <?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark">Read More >></a>
</div>
<?php endwhile; ?>
<div style="clear:both;"></div>
It kinda works, but it ends up pulling in the SAME thumbnail for every post instead of the thumnail/image tied to that post.
What am I doing wrong?