Hi all,

I am trying to create a page using WordPress which lists the categories with featured image tiles (the featured image coming from the most recent post in that category.

So far I have managed to get the image displaying, and the link after the the image, but the link is empty, I'd like the image to be within the link tags.

The PHP I am using is:

PHP Code:
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    <?php $category get_the_category(); 
        if(
$category[0]){
            echo 
'<a href="'.get_category_link($category[0]->term_id ).'">'.the_post_thumbnail('thumbnail').'</a>';
        }
    
?>
<?php 
endwhile; ?>
This is outputting:

HTML Code:
<img width="226" height="185" src="http://urltotheme.com/wp-content/uploads/2012/04/imgname-226x185.jpg" class="attachment-thumbnail wp-post-image" alt="" title="" />
<a href="http://urltotheme.com/themename/category/categoryname/"></a>
I wanted the image to be inside the anchor tags, or ideally, a slightly more advanced set up, outputting the anchor tag, with a header tag inside which contained the category name and then the image... so something like this:

HTML Code:
<a href="http://urltotheme.com/themename/category/categoryname/">
     <h2>Category Name</h2>
     <img width="226" height="185" src="http://urltotheme.com/wp-content/uploads/2012/04/imgname-226x185.jpg" class="attachment-thumbnail wp-post-image" alt="" title="" />
</a>
Is this doable?

Thanks so much for any help in advance.

Simon