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
| Field | Arguments | Returns | Description |
|---|---|---|---|
id | — | int | Attachment ID |
title | — | string | Attachment title |
name | — | string | Attachment name (alias for slug) |
slug | — | string | Attachment slug |
status | — | string | Attachment status |
content | — | string | Attachment description |
excerpt | — | string | Attachment caption |
file | — | string | Relative file path (to uploads folder) |
file_loc | — | string | Absolute file path on server |
extension | — | string | File extension |
size | — | int | File size in bytes |
mime_type | — | string | MIME type (application/pdf, video/mp4, etc.) |
link | — | string | Attachment page URL |
path | — | string | Attachment page path |
edit_link | — | string | Admin edit URL |
date | format | string | Upload date |
time | format | string | Upload time |
timestamp | — | int | Unix timestamp |
modified_date | format | string | Modified date |
modified_time | format | string | Modified time |
modified_timestamp | — | int | Modified unix timestamp |
author | — | User | Uploader |
parent | — | Post | Parent post |
can_edit | — | bool | Current user can edit |
meta | field_name | mixed | Attachment meta value |
raw_meta | field_name | mixed | Unescaped meta value |
has_field | field_name | bool | Check 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 }}
Link to download
<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 }}