Home Forums ACF PRO Trouble using add_sub_row() with nested repeater


Trouble using add_sub_row() with nested repeater

  • Hi there.
    I am trying to add data to a set of nested repeaters without using the ACF form. The parent repeater is ‘inventory2’ and the child/nested repeater is ‘feather_inventory’. Here is the code I’m using.

        if( have_rows('inventory2',2339) ):
            while ( have_rows('inventory2', 2339) ) : the_row();  
                        $row = array(
                            'matID' => 1245,
                            'material_colors'   => array('Yellow', 'Blue')
                        $add = add_sub_row('feathers_inventory', $row, 2339);
        else :

    When I execute this code it does add a row to the database but in a slightly different format…so the row doesn’t show up when looking at the ACF form.

    If I add an item through the form the format for the meta_key the DB is:
    inventory2_feathers_inventory_10_matID … the 10 being the row number

    If I execute the code above it starts a new set of rows with the format being:

    The issue being that it’s not adding another row to the end…it’s starting a new set of rows.

    I have tried several different iterations of nested have_rows loops, add_row(), add_sub_row(), update_field()…I just can’t get anything to stick.

    I’ll take any solution…but at the moment I’d just like to know why add_sub_row() isn’t tacking a new row on the end.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.