wp_attachment_caption()

Twig function of the framework; its result is HTML and is printed without escaping.

{{ wp_attachment_caption(id) }}

The caption of an attachment, as returned by wp_get_attachment_caption(). The caption is returned as stored: it may contain HTML, which WordPress filters with kses when a user without the unfiltered_html capability saves it (like the caption of the core image block). The output is HTML and is printed unescaped. Returns '' if the ID is null or the attachment does not exist.

<figcaption>{{ wp_attachment_caption(attrs.imageId) }}</figcaption>
ParameterTypeDefaultDescription
idint|nullrequiredID of the attachment.

Returns string