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!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.