Query to show images with recent posts in Wordpress sidebar/widget
Posted
by Peter
on Stack Overflow
See other posts from Stack Overflow
or by Peter
Published on 2010-04-11T19:51:26Z
Indexed on
2010/04/11
19:53 UTC
Read the original article
Hit count: 363
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?
© Stack Overflow or respective owner