get_the_post_thumbnail_caption

函式
get_the_post_thumbnail_caption ( $post = null )
引數
  • (int|WP_Post) $post Optional. Post ID or WP_Post object. Default is global `$post`.
    Required:
    Default: null
返回值
  • (string) Post thumbnail caption.
定義位置
相關方法
the_post_thumbnail_captionget_the_post_thumbnailget_the_post_thumbnail_urlget_the_post_navigationget_the_posts_navigation
引入
4.6.0
棄用
-

get_the_post_thumbnail_caption: 該函式返回當前文章或作為引數傳遞給它的文章的縮圖或特色圖片的標題。

返回文章的縮圖標題。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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;
}

常見問題

FAQs
檢視更多 >