Support

Account

Home Forums General Issues How to fill group field with data

Helping

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)

The topic ‘How to fill group field with data’ is closed to new replies.