has_post_thumbnail( int|WP_Post $post = null )
Check if post has an image attached.
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 |
---|---|
WP-4.4.0 | $post can be a post ID or WP_Post object. |
WP-2.9.0 | Introduced. |