get_the_post_thumbnail_caption() - WordPress 函数参考中文文档

返回介绍

get_the_post_thumbnail_caption()

发布于 2017-09-11 字数1506 浏览 893 评论 0

get_the_post_thumbnail_caption( int|WP_Post $post = null )

Returns the post thumbnail caption.


描述


参数

$post

(int|WP_Post)
(Optional)
Post ID or WP_Post object. Default is global $post.

Default value: 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 描述
4.6.0 Introduced.

相关函数

Uses

  • wp-includes/post.php:
    wp_get_attachment_caption()
  • wp-includes/post-thumbnail-template.php:
    get_post_thumbnail_id()

Used By

  • wp-includes/post-thumbnail-template.php:
    the_post_thumbnail_caption()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!