Posted By

peterbelsky on 02/22/10


Tagged

wordpress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

sandynata


Post Thumbnail Images


 / Published in: PHP
 

URL: http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/

  1. add_theme_support( 'post-thumbnails' );
  2.  
  3. or
  4.  
  5. add_theme_support( 'post-thumbnails', array( 'post' ) ); // Add it for posts
  6. add_theme_support( 'post-thumbnails', array( 'page' ) ); // Add it for pages
  7.  
  8. set_post_thumbnail_size( 50, 50 ); // 50 pixels wide by 50 pixels tall, box resize mode
  9.  
  10. <?php
  11. if ( has_post_thumbnail() ) {
  12. // the current post has a thumbnail
  13. } else {
  14. // the current post lacks a thumbnail
  15. }
  16. ?>
  17.  
  18.  
  19. <?php the_post_thumbnail(); ?>

Report this snippet  

You need to login to post a comment.