WordPress at a glance

has_post_thumbnail() WP 1.0

Check if post has an image attached.

  • Since 4.4.0 $post can be a post ID or WP_Post object.
Works based on: get_post_thumbnail_id()
✈ 1 time = 0.000032s = very fast | 50000 times = 0.47s = very fast PHP 7.0.5, WP 4.5.2

No Hooks.


true/false. Whether the post has an image attached.


has_post_thumbnail( $post );
Post ID or WP_Post object.
Default: global $post

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

function has_post_thumbnail( $post = null ) {
	return (bool) get_post_thumbnail_id( $post );

Related Functions

From tag: Thumbnail (images)

More from tag: Conditional tags (all)

More from category: Thumbnails

No comments
    Hello, !     Log In . Register