I have a site which has 1000+ posts, after recently adding a new custom field ( with ACF ) obviously that post_meta data will not excist until I have gone through every single post and updated it with a value.

So ive found this code :

function my_acf_load_value( $value, $post_id, $field ) {
    $value = get_the_title(); 
    return $value;
add_filter('acf/load_value/name=amazon_keywords', 'my_acf_load_value', 10, 3);

Which sets the default value of the field to the wp-title, so when I goto a post the post title is already entered in the custom field ready for me to save.

With that in mind, is there anyway I can do this without having to go into every single post and re-save it ? Like a bulk update ? I tried to bulk update from the post listings screen but it doesnt seem to execute the saving of custom fields.


You can add a new bulk action for posts with this code :

$postType = "post";

add_filter("bulk_actions-edit-" . $postType, function ($actions) {

    $actions["specialSave"] = "Special save";

    return $actions;

}, 20);

add_filter("handle_bulk_actions-edit-" . $postType, function ($sendback, $doaction, $post_ids) {

    if ("specialSave" !== $doaction) {

    foreach ($post_ids as $idPost) {

        // action to do for each selected post


    return $sendback;

}, 10, 3);

is a simple save is not enough to set the value, you can use this code to set the value directly for each selected post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.