Home › Forums › Add-ons › Repeater Field › Iterating a repeater field in acf/save_post › Reply To: Iterating a repeater field in acf/save_post
this is incorrect
/*
This first line gets the entire repeater and store it in an array
If you are going to use have_rows() then this is unnecessary
*/
$person_relationships = get_field('person_relationships', $post_id);
/*
With the above $person_relationships
holds an array of rows and not a field name
*/
while (have_rows($person_relationships)) : the_row();
// Do something
endwhile;
What you need to do is just the loop and not the first part
if (have_rows(''person_relationships', $post_id)) {
while (have_rows(''person_relationships', $post_id)) {
the_row();
// do something
}
}
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.