Query to show images with recent posts in Wordpress sidebar/widget
- by Peter
To show recent items from a Wordpress category in a widget I'm using this code...
<ul>
<?php $recent = new WP_Query("cat=1231&showposts=5"); while($recent->have_posts()) :
$recent->the_post();?>
<li><a href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); ?>
</a></li>
<?php endwhile; ?>
</ul>
...but how can I make this query also display the first image in each post, and is there any way to set a 'default' image in case there is no image?
Is there also a way to use thumbnails here, rather than loading the full size image and using HTML to resize?