Home › Forums › General Issues › Update all posts at once
Great plugin! I’ve one issue, maybe a beginner’s one.
I have changed the value of the choices in a checkbox custom field . Is there any way to update at once all posts with this field that were edited before?
Thank you very much
Hi @nserrat
Sorry, this functionality does not yet exist.
Could you please explain what you changed, and what you would expect from this feature?
Thanks
E
Of course.
The issue is because of I had changed the value of the choices in a checkbox custom field without I realised I would need update the posts. Now, I’ve many posts with the old value and many others with the new one. This is a problem in searching, but besides, its a problem when is need to edit one posts because the old value selected it doesn’t appears and the update isn’t done because can’t validate ( it’s an required field)
Now I need to verify the value in each post, and update it. I was looking for another solution, may be updating de databse from the plugin.
Thanks a lot
Hi @nserrat
Currently, there is no tool for bulk update. But I like the idea.
I’ll add this to the to-do.
Thanks
E
Hi Elliot,
Wondering if this still in the cards? I’ve been also desperately looking for the same thing. My Google searches have pointed me to this post: http://jboullion.com/update-post-acf-fields/
However, I’ve miserably failed trying to make it work. But perhaps it could give you guys some ideas about how to implement it?
Fingers crossed!
Could this be achieved by creating a wp_query(); for all posts with an update_field(); function in it?
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
For anyone who comes across this, the best solution that I found was this tool: https://github.com/mcguffin/acf-quick-edit-fields
This saved me an hour or two of manually updating 181 posts. After installing that plugin, I edited the ACF field and checked off the option “Allow editing this field in Bulk edit mode” then I was able to bulk edit the posts and update the field.
The topic ‘Update all posts at once’ is closed to new replies.
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.