Skip to content

File Field in WordPress

Key Takeaways

  • Nexter Extension stores a file field as a reference to a media library attachment, and Return Format can give the attachment ID, the URL, or an array with the filename, size, and MIME type.
  • Nexter Extension 4.9.0 exposes file field settings across four tabs: General, Validation, Presentation, and Conditional Logic, with options such as Required, Allowed File Types, Minimum, Maximum, Instructions, Wrapper Attributes, and Conditional Logic.
  • Nexter Extension limits a file field to one file per field, and the post says a repeater with a file sub-field is the way to handle several files.
Table of Contents

A file field lets an editor attach a document — a brochure, a spec sheet, a price list — from the media library, so it can be offered as a download without pasting a URL.

What It Does

The field stores a reference to a media library attachment. Return Format decides whether your template gets the attachment ID, the URL, or an array with the filename, size and MIME type.

Before You Start

  • Nexter Extension is installed and active.
  • Content Fields is enabled under Nexter → Content Fields.
  • You have a field group, or are about to create one.

Add a File Field

  1. Go to Nexter → Content Fields and open the Group Fields tab.
  1. Open a field group, or create a new one.
  1. Click Add Field.
A field group open with the Add Field button
  1. Set Field Label to Brochure (PDF). The Field Name fills in automatically and is what you use in code.
  1. Set Field Type to File.
The Field Type dropdown listing the available field types
  1. Choose a Return Format.
The File field settings in the Content Fields builder
  1. Set Library if editors should only pick files uploaded to this post.
  1. Click Update.
The File field as it appears on the post editing screen

Field Settings

Every field is configured across four tabs. These are the settings this field type offers, read from the field group builder in Nexter Extension 4.9.0.

General

SettingOptionsWhat it does
Return FormatNo help text in the UI.
LibraryNo help text in the UI.

Validation

SettingOptionsWhat it does
RequiredNo help text in the UI.
Allowed File TypesNo help text in the UI.
MinimumNo help text in the UI.
MaximumNo help text in the UI.

Presentation

SettingOptionsWhat it does
InstructionsNo help text in the UI.
Wrapper AttributesNo help text in the UI.

Conditional Logic

SettingOptionsWhat it does
Conditional LogicNo help text in the UI.

When to Use It

  • A brochure or spec sheet on a listing.
  • A menu or price list on a venue.
  • A manual or datasheet on a product.

Display the Value

With an ID returned, build the download link from the attachment:

<?php
$id = nxt_field_value( 'brochure' );
if ( $id ) {
    printf(
        '<a href="%s" download>%s</a>',
        esc_url( wp_get_attachment_url( $id ) ),
        esc_html( get_the_title( $id ) )
    );
}

Limitations

  • The file is stored in the media library, so it is publicly reachable by URL. Do not use a file field for anything that must stay private.
  • One file per field. For several, use a repeater with a file sub-field.

Troubleshooting

The upload is rejected

WordPress blocks file types not on its allowed list. Check the extension is permitted for your site before assuming the field is at fault.

The link is broken

The attachment was deleted from the media library while the ID remained stored. Check the value resolves before rendering.

Related Docs

Share your Thoughts

Still in Doubt? Let’s Assist You

Have Feedback or Questions?

Join our WordPress Community on Facebook!

Related Frequently Asked Questions

How do I add a file field in WordPress for a brochure or PDF download?

A file field stores a media library attachment, so it works well for a brochure or PDF without pasting a raw URL into content. In Nexter Extension, the field label can be set to something like Brochure (PDF), and the field name is what you use in code. The key choice is Return Format, because it controls whether you get the attachment ID, the URL, or an array with filename, size, and MIME type.

Why is my WordPress file upload being rejected?

WordPress blocks file types that are not on its allowed list, so a rejected upload usually points to the site’s file-type rules rather than the field itself. That matters because the file field only stores a media library attachment, it does not override WordPress upload restrictions. If the extension is not permitted for your site, the upload will fail before the field can save it.

What is the best return format for a WordPress file field?

The best return format depends on how you plan to use the value. An ID is the most flexible if you want to build your own download link in PHP, while a URL is simpler when you only need the direct file address. The array option gives extra metadata like filename, size, and MIME type, which is useful when templates need more than just a link.

Can I use a WordPress file field for private documents?

A file field is a bad fit for private documents because the file lives in the media library and is publicly reachable by URL. That means anyone who has or guesses the link can access it. For anything that must stay private, this setup is not appropriate. It works better for public downloads like brochures, spec sheets, menus, price lists, manuals, or datasheets.

How do I show a downloadable file link from a WordPress file field?

When the field returns an ID, you can turn that attachment into a download link with `wp_get_attachment_url( $id )` and use `get_the_title( $id )` as the link text. That approach keeps the template tied to the media library record instead of hardcoding a URL. The page’s example also adds `download`, which nudges browsers toward downloading instead of opening inline.

Why does my WordPress file field link break after I delete media?

A broken link usually means the attachment was deleted from the media library while its ID was still stored in the field. The saved value can still exist even when the actual file record is gone, so rendering blindly will produce a dead link. The safe pattern is to check that the value resolves before outputting it on the front end.

Last reviewed: November 12, 2026

Related Docs