Support

Account

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
      }
    }