wp_get_attachment_caption()
Retrieves the caption of specified attachment.
Caption and title are different things. Do not confuse them:
Used By: get_the_post_thumbnail_caption()
1 time — 0.000544 sec (slow) | 50000 times — 0.36 sec (very fast) | PHP 7.0.8, WP 4.6
Hooks from the function
Return
String|false
. Attachment caption on success, false on failure.
Usage
wp_get_attachment_caption( $post_id );
- $post_id(int/WP_Post)
- ID or WP_Post object of the attachment.
Default: current post
Examples
#1 Get the caption of the attachment image
Let's say we have an attachment with ID 654 and the caption "Today I caught such a big fish here!" then:
echo wp_get_attachment_caption( 654 ); //> output: Today I caught such a big fish here!
Changelog
Since 4.6.0 | Introduced. |