get_the_post_thumbnail_caption

Returns the post thumbnail caption.

Description

(string) get_the_post_thumbnail_caption( (null) $post = null ); 

Returns (string)

Post thumbnail caption.

Parameters (1)

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

Usage

  1. if ( !function_exists( 'get_the_post_thumbnail_caption' ) ) { 
  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 = get_the_post_thumbnail_caption($post); 
  9.  

Defined (1)

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

/wp-includes/post-thumbnail-template.php  
  1. function get_the_post_thumbnail_caption( $post = null ) { 
  2. $post_thumbnail_id = get_post_thumbnail_id( $post ); 
  3. if ( ! $post_thumbnail_id ) { 
  4. return ''; 
  5.  
  6. $caption = wp_get_attachment_caption( $post_thumbnail_id ); 
  7.  
  8. if ( ! $caption ) { 
  9. $caption = ''; 
  10.  
  11. return $caption;