Support

Account

Home Forums Backend Issues (wp-admin) update_field() issues Reply To: update_field() issues

  • Hi squarestarmedia,

    As you have observed, ACF needs to have a value present on a Post Object for field name<->field key lookups to function correctly.

    The solution would be to use the repeater field’s key, (e.g. ‘field_abcdef123456’) instead of the name (e.g. ‘repeater_name’) when referencing the repeater.

    If I understand your use case correctly, you might also want to purge all rows in the repeater, and then add the taxonomies, so as not to have stale taxonomies should some be removed (either as non-hierarchical, or as a change in structure for hierarchical taxonomies).

    Example:

    
    <?php
    // For every row in the repeater
    while ( have_rows( 'field_abcdef123456' ) ) {
        // Delete the first row, until it is empty
        delete_row('field_abcdef123456', 1);
    }
    
    // For each taxonomomy...
    add_row( 'field_abcdef123456', array(
        'sub-field-name-or-key' => 'sub-field-value',
        // ...
    ) );
    

    ——————

    Help your fellow forum-goers and moderation team; if a response solves your problem, please mark it as the solution. Thank you!