WordPress at Your Fingertips

the_post_thumbnail_caption() WP 4.6.0

Displays the post thumbnail caption.

Use get_the_post_thumbnail_caption() to get a caption for further processing in PHP.

The caption is specified when editing the image in the admin panel:

1 time — 0.001038 sec (very slow) | 50000 times — 1.91 sec (fast) | PHP 7.0.8, WP 4.6
Hooks from the function

null. Nothing (null). Displays the caption.


the_post_thumbnail_caption( $post );
Post ID or WP_Post object.
Default: global $post


#1 Get post thumbnail caption

The function will print an empty string if the thumbnail has no caption. Not confuse the thumbnail title and thumbnail caption.

<?php the_post_thumbnail_caption( 6462 ); ?>


Since 4.6.0 Introduced.

Code of the_post_thumbnail_caption() WP 5.8

function the_post_thumbnail_caption( $post = null ) {
	 * Filters the displayed post thumbnail caption.
	 * @since 4.6.0
	 * @param string $caption Caption for the given attachment.
	echo apply_filters( 'the_post_thumbnail_caption', get_the_post_thumbnail_caption( $post ) );

From tag: Thumbnail (images)

More from category: Thumbnails

vladlu 100vlad.lu
Editors: Kama 100
No comments
    Log In