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
            case 'Y':
              $value[$index] = 2;
            // etc for other values you changed
              // don't change by default
          } // end switch
        } // end foreach
      } // end if array
      return $value;
    } // end function