Posted By

pirazo on 01/19/11


Tagged

loop wp


Versions (?)

Recent Posts Loop with WP Thumbnail


 / Published in: PHP
 

No plugin necessary, uses "loop" and default WP Thumnail

  1. <?php $recent = new WP_Query("category_name=blog,news&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
  2. <div class="hmpg-blog-post">
  3. <div class="hmpg-blog-postimage">
  4. <?php if (function_exists('has_post_thumbnail')) { if ( has_post_thumbnail() ) { ?>
  5. <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( array(100,100 )); ?></a>
  6. <?php } else { ?>
  7. <a href="<?php the_permalink(); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/hmpg-blog-thumb.jpg" width="100px" height="100px" border="0" alt="<?php bloginfo('name'); ?>" /></a>
  8. <?php } } ?>
  9. </div><!-- hmpg-blog-postimage -->
  10. <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  11. <?php the_content_limit(160, "Read more"); ?>
  12. </div><!-- hmpg-blog-post -->
  13. <?php endwhile; ?>

Report this snippet  

You need to login to post a comment.