Home › Forums › General Issues › Update all posts at once › Reply To: Update all posts at once
More than likely 1) if you have a lot of posts it will time out your site. 2) If your problem is that the field_key references are not being added in the export/import then the code that is linked to will not work. In order to get them to update properly you need to use the field key for each field in update_field().
In the case of updated the values that a field can have, I would use an acf/load_value filter…. this one specifically for a checkbox
add_filter('acf/load_value/name=your_field_name', 'my_updated_checkbox_values', 10, 3);
function my_updated_checkbox_values($values, $post_id, $field) {
if (is_array($values)) {
foreach ($values as index => $value) {
switch($value) {
case 'X': // old value
$value[$index] = 1; // set to new value
break;
case 'Y':
$value[$index] = 2;
break;
// etc for other values you changed
default:
// don't change by default
break;
} // end switch
} // end foreach
} // end if array
return $value;
} // end function
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.