Skip to main content

Attachment

Attachment objects represent non-image file attachments in WordPress (PDFs, documents, videos, audio files, etc.). Like Image, you don't access attachments directly as a root provider — they appear when iterating over attachments in a Loop block or chaining into attachment fields.

For image attachments, see Image.

All Fields

FieldArgumentsReturnsDescription
idintAttachment ID
titlestringAttachment title
namestringAttachment name (alias for slug)
slugstringAttachment slug
statusstringAttachment status
contentstringAttachment description
excerptstringAttachment caption
filestringRelative file path (to uploads folder)
file_locstringAbsolute file path on server
extensionstringFile extension
sizeintFile size in bytes
mime_typestringMIME type (application/pdf, video/mp4, etc.)
linkstringAttachment page URL
pathstringAttachment page path
edit_linkstringAdmin edit URL
dateformatstringUpload date
timeformatstringUpload time
timestampintUnix timestamp
modified_dateformatstringModified date
modified_timeformatstringModified time
modified_timestampintModified unix timestamp
authorUserUploader
parentPostParent post
can_editboolCurrent user can edit
metafield_namemixedAttachment meta value
raw_metafield_namemixedUnescaped meta value
has_fieldfield_nameboolCheck if field exists

Basic Fields

{{ item.id }}
{{ item.title }}
{{ item.slug }}

Content

{{ item.content }}      <!-- Description -->
{{ item.excerpt }} <!-- Caption -->

File Info

{{ item.file }}
{{ item.file_loc }}
{{ item.extension }}
{{ item.size }}
{{ item.mime_type }}

URLs

{{ item.link }}
{{ item.path }}
{{ item.edit_link }}

Dates

{{ item.date('F j, Y') }}
{{ item.timestamp }}
{{ item.modified_date('Y-m-d') }}

Author & Parent

{{ item.author.name }}
{{ item.parent.title }}

Custom Fields (Meta)

{{ item.meta('custom_field') }}
{{ item.has_field('download_count') }}

Note: Private meta keys (starting with _) are blocked for security.

Common Patterns

Display file type badge

{{ item.extension|upper }}
<a href="{{ item.link }}">{{ item.title }} ({{ item.extension|upper }})</a>

Show file size

{{ item.size|number_format }} bytes

File type icon class

file-{{ item.extension }}