get_the_post_thumbnail_caption() WordPress Function
The get_the_post_thumbnail_caption() function is used to retrieve the caption for a post thumbnail. This function will return an empty string if there is no caption for the thumbnail.
get_the_post_thumbnail_caption( int|WP_Post $post = null ) #
Returns the post thumbnail caption.
Parameters
Return
(string) Post thumbnail caption.
Source
File: 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; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.6.0 | Introduced. |