Function: the_post_thumbnail

the_post_thumbnail( string | array $size, string | array $attr )

Display the post thumbnail.

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

Name Type(s) Default Value Description
$size string | array 'post-thumbnail'

Optional. 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'.

$attr string | array ''

Optional. Query string or array of attributes. Default empty.

WordPress Developer Newsletter

Stay on top of the latest WordPress API changes, developer tool updates, security alerts and more.