Home › Forums › Add-ons › Repeater Field › Adding subfields to Repeater Field › Reply To: Adding subfields to Repeater Field
Going to be honest, outside of the documentation I’m not really sure. I think that the problem has something to do with inserting post and data during the import. I’ve done this before and importing comes with it’s own problems. Usually the way I do this is to completely skip the ACF functions and either go right to the database or use add_post_meta(). I can’t say if this would be helpful in your case or not.
Usually, with what you are seeing, being able to get the content on the front end and not seeing them in the back end, is a sign that the field key references are not being inserted properly. So it appears that for some reason the keys are not being updated correctly.
Again, not sure it this will help you, but it’s an example of how to add post meta values that will be correct.
// one repeater field with one sub field
$repeater_name = 'repeater';
$repeater_key = 'field_1234567890123';
$subfield_name = 'sub_field';
$subfield_key = 'field_2345678901234';
$data = array('row 1', 'row_2', 'etc'); // represents your data to insert
$count = count($data);
if ($count) {
add_post_meta($post_id, $repeater, $count, true);
add_post_meta($post_id, '_'.$repeater, $repeater_key, true);
for ($i=0; $i<$count; $i++) {
$meta_key = $repeater.'_'.$i.'_'.$subfield_name;
add_post_meta($post_id, $meta_key, $data[$i], true);
add_post_meta($post_id, '_'.$meta_key, $subfield_key, true);
}
}
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.