WordPress at a glance

the_post_thumbnail() WP 1.0

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.

  • See: get_the_post_thumbnail()
Works based on: get_the_post_thumbnail()
✈ 1 time = 0.001739s = very slow | 50000 times = 6.79s = fast PHP 7.1.2, WP 4.7.3

No Hooks.

Return

Nothing (null).

Usage

the_post_thumbnail( $size, $attr );
$size(string/array)
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)
Query string or array of attributes.
Default: ''

Code of the_post_thumbnail: wp-includes/post-thumbnail-template.php VER 4.9.8

<?php
function the_post_thumbnail( $size = 'post-thumbnail', $attr = '' ) {
	echo get_the_post_thumbnail( null, $size, $attr );
}

Related Functions

From tag: Thumbnail (images)

More from category: Thumbnails

No comments
    Hello, !     Log In . Register