Home › Forums › Feature Requests › Starting Rows – Repeater Field › Reply To: Starting Rows – Repeater Field
This can be done with the acf/load_value filter https://www.advancedcustomfields.com/resources/acfload_value/.
add_filter('acf/load_value/name='your-repeater-field-name', 'your_set_repeater_default_values_function_name', 10, 3);
function your_set_repeater_default_values_function_name($value, $post_id, $field) {
if ($value !== NULL) {
// value will be exactly NULL if the field has never been updated
// ie on a new post. If it is not null then you don't want to
// overwrite what's there
return $value;
}
// set new value
$value = array(
// a nested array for each row
array(
// and array item for each field
// use field keys
'field_1234567890abc' => 'default value',
'field_01234567890ab' => 'default value',
// etc...
),
// another row
array(
// etc...
),
);
}
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.