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

Wokiee React eCommerce Template