has_post_thumbnail

Check if post has an image attached.

Description

has_post_thumbnail( (null) $post = null ); 

Parameters (1)

0. $post — Optional. (null) => null
Post ID or WP_Post object. Default is global $post..

Usage

  1. if ( !function_exists( 'has_post_thumbnail' ) ) { 
  2. require_once ABSPATH . WPINC . '/post-thumbnail-template.php'; 
  3.  
  4. // Optional. Post ID or WP_Post object. Default is global `$post`. 
  5. $post = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = has_post_thumbnail($post); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/post-thumbnail-template.php  
  1. function has_post_thumbnail( $post = null ) { 
  2. return (bool) get_post_thumbnail_id( $post );