get_post_thumbnail_id( int|WP_Post $post = null )
Retrieve post thumbnail ID.
Parameters
Return
(string|int) Post thumbnail ID or empty string.
Source
File: wp-includes/post-thumbnail-template.php
function get_post_thumbnail_id( $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return '';
}
return get_post_meta( $post->ID, '_thumbnail_id', true );
}
Changelog
Version | Description |
---|---|
WP-4.4.0 | $post can be a post ID or WP_Post object. |
WP-2.9.0 | Introduced. |