File field
Purpose
Any file from the media library: PDF, ZIP, document, audio…
Field type name
file
Settings
| Setting | Description |
|---|---|
| Instructions | Shown to editors below the field label. (max 2000 characters) |
| Return Format | What cafe_get_field() returns. |
| Allowed File Types | File types editors may upload, picked from a grouped dropdown (PDF, Word .doc/.docx, Excel .xls/.xlsx, CSV, PowerPoint, images, ZIP, …) or typed as MIME types. Empty = every type WordPress accepts. |
| Default File | Attachment ID returned when nothing has been saved yet. (min 1, whole number) |
| Translation | How the field behaves in other languages: translate, copy, copy_once or do_not_translate. Used on top-level fields when WPML is active. See WPML. |
| Width | Width on edit screens, to place fields side by side: 100 (full), 75, 66, 50, 33 or 25 (%). Phones always show full width. |
| Label per language | The label and instructions per language code while editing in that language, e.g. {"nl": {"label": "Prijs"}}. Set on the Translation tab when WPML is active. See WPML. |
PHP return value
Return Format array (default):
[
'id' => 123,
'url' => 'https://example.com/wp-content/uploads/2026/09/brochure.pdf',
'filename' => 'brochure.pdf',
'title' => 'brochure',
'mime_type' => 'application/pdf',
'filesize' => 123456, // bytes, from attachment metadata; null when unknown
]
id or url return formats are also available. A deleted attachment reads as null.
Example
$file = cafe_get_field( 'brochure' );
if ( $file ) {
printf(
'<a href="%1$s" download>%2$s (%3$s)</a>',
esc_url( $file['url'] ),
esc_html( $file['title'] ),
esc_html( size_format( (int) $file['filesize'] ) )
);
}