I'm using the excellent PHP Code Widget plugin, and want to create a widget that displays the post thumbnail (aka featured image) for the most recent 'project' post. Here's the code I have so far, but it isn't producing the desired result. This actually outputs nothing.
<?php
global $post;
$args = array(
'post_type' => 'project',
'posts_per_page' => 1,
);
$thumbnails = get_posts($args);
foreach ($thumbnails as $post)
{
setup_postdata($post);
?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'thumbnail' ); ?></a>
<?php
}
Any suggestions on what I need to change for this to work?
$thumbnailsis not empty? – Rarst♦ Dec 8 '10 at 20:08