Home › Forums › Backend Issues (wp-admin) › Pre populate repeater in a flexible content › Reply To: Pre populate repeater in a flexible content
I haven’t found a solution for this but I found another solution that fit my problem, with this code is possible to pre-populate nested fields with some default value:
add_filter('acf/load_value/key=field_607879a1215fc', 'acf_load_default', 10, 3);
function acf_load_default($value, $post_id, $field)
{
if ($value === false) {
$value = array();
$value[] = array(
'field_6081eeaf5a418' => 'Example Title One',
);
$value[] = array(
'field_6081eeaf5a418' => 'Example Title Two',
'field_6081eeb75a419' => array(
array('field_6081eebf5a41a' => 'Example Title Three'),
array('field_6081eebf5a41a' => 'Example Title Four')
)
);
}
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.