Home › Forums › General Issues › update_field not updating fiel › Reply To: update_field not updating fiel
Did you read the solution I gave in the other topic?
Here it is adapted for your field keys
// initialize row value just in case the loop returns noting
$row = array();
// loop group field and get existing values
if (have_rows('field_64b38c4e3ec56', $post_id)) {
// this is always true once
while (have_rows('field_64b38c4e3ec56', $post_id)) {
// this loop always happens 1 time for a group field
// *********************************************************
// little known fact
// the_row() returns an array holding the row
// with field keys as indexes and unformatted field values
// *********************************************************
$row = the_row();
}
}
// set a new value for the "sub field" that needs to be updated.
$row['field_64c782fc4c55d'] = 'value you want to update to here';
// update the group field
update_field('field_64b38c4e3ec56', $row, $post_id);
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.