Wordpress - Recent Post


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <div id="recentPost">
  2.  
  3. <ul>
  4. <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
  5.  
  6. <li>
  7.  
  8. <div class="column <?php if($i == 4 || $i == 8 || $i == 12 ): ?>last<?php endif; ?>">
  9.  
  10. <?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : /* if post has post thumbnail */ ?>
  11.  
  12. <div class="image"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('related-thumbnail'); ?></a></div>
  13.  
  14. <?php endif; ?>
  15.  
  16. <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
  17.  
  18. </div><!--column-->
  19.  
  20. </li>
  21. <?php $i++; ?>
  22. <?php endwhile; ?>
  23. </ul>
  24. </div>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.