Home Forums General Issues How to fill group field with data


How to fill group field with data

  • Hi, i have group filed with few sub fields and i want to fill it with data. Using if( have_rows('fotografie') ): while( have_rows('fotografie') ) : the_row(); doesnt work because it doesnt have any row yet. add_row() didnt work either. Anyone know how to do this?

  • When updating a field that does not exist yet you need to use the field key rather than the field name.

    When dealing with a group field, it can only have one row so I would bypass the loop and add_row and to

    $value = array(
      // sub field key/value pairs
      'field_12345' => 'value 1',
      'field_34567' => 'value 2',
      // etc....
    update_field('field_xyz123', $value, $post_id);
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.