Home › Forums › Add-ons › Repeater Field › Fill up repeater fields with category › Reply To: Fill up repeater fields with category
You need to do this on the load value hook for the repeater
example:
add_filter('acf/load_value/name=your-repeater-field-here', 'preload_repeater', 20, 3);
function preload_repeater($value, $post_id, $field) {
if (!empty($value)) {
// this repeater already has a value do not change it
return $value
}
// code here to populate repeater
// this is an example of what ACF is expecting for the value
// the repeater value is an array
$value= array(
// each row is a nested array
array(
// each nested row array is made up of "field key" => "value pairs"
'field_012345' => 'value for this sub field',
'field_123456' => 'value for 2nd sub field',
// etc....
),
// second row
array(
// etc...
),
// etc...
);
return $value;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.