Custom posts Thumbnails with link to post


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

am using this in my home page, next to other queries to show normal posts.
Note:
Change books to your custom post name.
latestbookssize is the class I am using in the code below to style the thumbnail.


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. // The Query
  4. query_posts( array( 'post_type' => 'books' ), 'showposts=4' );
  5.  
  6. // The Loop
  7. while ( have_posts() ) : the_post();
  8. echo '<a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';
  9. echo get_the_post_thumbnail($thumbnail->ID, 'single-post-thumbnail', array('class' => 'latestbookssize'));
  10. echo '</a>';
  11. endwhile;
  12.  
  13. // Reset Query
  14. wp_reset_query();
  15. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.