Monday, December 19, 2016

WP -> ACF insert file into a File field inside of a repeater

In ACF, a File type is populated by providing an attachment (post) ID of the file.

Repeater field is populated by an array of arrays, where each nested array represents a single row in the repeater field.

In order to everything work properly all the time, you should provide ACF field keys instead of field names, for your repeater fields.

Here's a code which takes an uploaded file (using normal HTML Input File control) and saves it as a WP attachment:

After that, this attachment ID is used to populate the File field inside a repeater like this:

//$attach_id is obtained from the upload function. It's the attachment ID


"file_upload" => $attach_id,
"file_ description" => "DESC $attach_id",
"file_date" => date("Ymd")




No comments:

Post a Comment

Ubuntu 12.04, 14.04, 16.04 - auto start an app or script before login

To run a command or application at startup, even before the user has logged in, you can use this file: /etc/rc.local The commands entered...