A WordPress-centric search engine for devs and theme authors



get_post_thumbnail_id ›

Since2.9.0
Deprecatedn/a
get_post_thumbnail_id ( $post = null )
Parameters:
  • (int|WP_Post) $post Optional. Post ID or WP_Post object. Default is global `$post`.
    Required: No
    Default: null
Returns:
  • (string|int) Post thumbnail ID or empty string.
Defined at:
Codex:
Change Log:
  • 4.4.0

Retrieve post thumbnail ID.



Source

function get_post_thumbnail_id( $post = null ) {
	$post = get_post( $post );
	if ( ! $post ) {
		return '';
	}
	return get_post_meta( $post->ID, '_thumbnail_id', true );
}