has_post_thumbnail( int|WP_Post $post = null )
Determines whether a post has an image attached.
Description
For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.
Parameters
- $post
-
(Optional) Post ID or WP_Post object. Default is global
$post
.Default value: null
Return
(bool) Whether the post has an image attached.
Source
File: wp-includes/post-thumbnail-template.php
function has_post_thumbnail( $post = null ) {
return (bool) get_post_thumbnail_id( $post );
}
Changelog
Version | Description |
---|---|
4.4.0 | $post can be a post ID or WP_Post object. |
2.9.0 | Introduced. |