Bootstrap Templates Bundle

Wednesday, January 23, 2013

How to display recent with thumbnail by specific category

Paste this below code where you want to show recent post with thumbnail


<?php
$the_query = new WP_Query('cat=3&showposts=5&orderby=post_date&order=desc');
while ($the_query->have_posts()) : $the_query->the_post(); ?>
<div style="margin-bottom: 2px;">
<?php the_post_thumbnail(array(50,50), array ('class' => 'alignleft')); ?>
<a title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
<?php the_excerpt(); ?>
<div class="clear"></div>
</div>

<?php endwhile; ?>
<?php wp_reset_query(); ?>
</li>

You can neglect  <?php the_excerpt(); ?>  if you want to show only post title with thumbnail

No comments:

Post a Comment

Best Pest Control WordPress Themes 2017

A collection of best pest control WordPress Themes for pest control service providers.  Link:   https://devitems.com/review/best-pest-co...