函数原型
get_the_post_thumbnail_caption( int|WP_Post $post = null ): string
函数描述
Returns the post thumbnail caption.
是否弃用
未弃用
函数参数
-
$post
int|WP_Post
Optional - Post ID or WP_Post object. Default is global
$post.Default:
null
函数返回值
string Post thumbnail caption.
函数位置
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;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 4.6.0 | Introduced. |

