Support

Account

Home Forums Add-ons Repeater Field wp_insert_post and repeater fields Reply To: wp_insert_post and repeater fields

  • Thanks for pointing me towards those resources. I pieced things together and came up with the following…

    
    $field_key = 'field_123123123123';
    $subfield_key = 'field_456456456456'; // corresponds with my-class-item in my previous post
    $post_id = $the_post_id; // gets current post ID
    $items = array('class 1','class 2','class 3');
    foreach ($items as $items_value) {
    	$value[] = array($subfield_key => $items_value);
    	update_field( $field_key, $value, $post_id );
    }
    

    It’s not a game changer, but is there any way to use the name of the custom field instead of the field key (e.g. “my-class-item” instead of “field_456456456456”)?