<?php
$parent = get_cat_ID("photos");
$cats = get_categories("child_of=".$parent);
foreach ($cats as $cat) {
query_posts("posts_per_page=1&orderby=rand&cat=".$cat->cat_ID);
?>
<?php if ($parent == true && have_posts()) : while (have_posts()) : the_post(); ?>
<ul>
<?php if (has_post_thumbnail()) { ?>
<?php
printf( '<li><a href="'.get_category_link($cat->cat_ID).'">'.get_the_post_thumbnail(get_the_ID(), "album-thumb").'</a><a href="'.get_category_link($cat->term_id).'">%s</a></li>',
apply_filters('get_term', $cat->name));
?>
<?php } ?>
</ul>
<?php endwhile; endif; } ?>
<?php if (! $parent == true || ! $cat == true) { ?>
<p><?php _e("Sorry, no posts matched your criteria."); ?></p>
<?php } ?>
<?php wp_reset_query(); ?>