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
if ( !function_exists( 'get_the_post_thumbnail_caption' ) ) { require_once ABSPATH . WPINC . '/post-thumbnail-template.php'; } // Optional. Post ID or WP_Post object. Default is global `$post`. $post = null; // NOTICE! Understand what this does before running. $result = get_the_post_thumbnail_caption($post);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/post-thumbnail-template.php
- function get_the_post_thumbnail_caption( $post = null ) {
- $post_thumbnail_id = get_post_thumbnail_id( $post );
- if ( ! $post_thumbnail_id ) {
- return '';
- }
- $caption = wp_get_attachment_caption( $post_thumbnail_id );
- if ( ! $caption ) {
- $caption = '';
- }
- return $caption;
- }