I am building a category overview page and i am use this code:
<?php
$limit = 999;
$counter = 0;
$categories = get_categories();
foreach ($categories as $category):
if ($counter < $limit) {
$args = array(
'category__in' => array(
$category->term_id
),
'caller_get_posts' => 1
);
$posts = get_posts($args);
if ($posts) {
echo '<div class="category">';
echo '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . '>';
echo '<h3>' . $category->name . '</h3>';
echo '</a>';
echo '</div>';
}
}
$counter++;
endforeach;
?>
But how to insert in the echo that the featured image from the last post in that category will be displayed.