This documentation describes unreleased changes on the main branch.

wp_attachment_url()

Twig function of the framework; its result is escaped like any value.

{{ wp_attachment_url(id) }}

The URL of the file of an attachment (any type, e.g. a PDF), as returned by wp_get_attachment_url(). Returns '' if the ID is null or the attachment does not exist.

<a href="{{ wp_attachment_url(attrs.fileId) }}" download>Download</a>
ParameterTypeDefaultDescription
idint|nullrequiredID of the attachment.

Returns string