Function: has_post_thumbnail

has_post_thumbnail( integer | WP_Post $post )

Determines whether a post has an image attached.

For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.

Parameters

Name Type(s) Default Value Description
$post integer | WP_Post null

Optional. Post ID or WP_Post object. Default is global $post.

Returns

boolean

Whether the post has an image attached.

WordPress Developer Newsletter

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