I'm trying to get a page to list all the child categories and then display their name and a thumbnail from the most recent post in that category.
This is the following code I've got, it appears to be fetching some thumbnails from other posts that aren't in the category and also repeating the categories.
Any help would greatly be appreciated.
<?php get_header(); ?>
<div id="left_full">
<?php
$args = array(
'orderby' => 'name',
'order' => 'ASC',
'child_of' => '3592'
);
$categories = get_categories($args);
foreach($categories as $category) {
query_posts( $category->name . 'posts_per_page=1' );
while ( have_posts() ) : the_post();
echo '<div class="interview_item">';
echo '<div class="interview_thumb"><a href="#" rel="bookmark">'; the_post_thumbnail('interview-thumb'); echo '</a></div>';
echo '<h1><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </h1> ';
echo '</div>';
endwhile;
wp_reset_query();
}
?>
</div>
</div>
<?php get_footer(); ?>