the_post_thumbnail

Display the post thumbnail.

Description

the_post_thumbnail( (string) $size = 'post-thumbnail', (string) $attr = '' ); 

When a theme adds post-thumbnail support, a special post-thumbnail image size is registered, which differs from the thumbnail image size managed via the Settings > Media screen.

When using the_post_thumbnail() or related functions, the post-thumbnail image size is used by default, though a different size can be specified instead as needed.

Parameters (2)

0. $size — Optional. (string) => 'post-thumbnail'
Image size to use. Accepts any valid image size, or an array of width and height values in pixels (in that order). Default post-thumbnail..
1. $attr — Optional. (string) => ''
Query string or array of attributes. Default empty.

Usage

  1. if ( !function_exists( 'the_post_thumbnail' ) ) { 
  2. require_once ABSPATH . WPINC . '/post-thumbnail-template.php'; 
  3. $size = 'post-thumbnail'; 
  4.  
  5. // Optional. Query string or array of attributes. Default empty. 
  6. $attr = ''; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = the_post_thumbnail($size, $attr); 
  10.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/post-thumbnail-template.php  
  1. function the_post_thumbnail( $size = 'post-thumbnail', $attr = '' ) { 
  2. echo get_the_post_thumbnail( null, $size, $attr );