Home Forums Add-ons Gallery Field Convert Attachments to Gallery Reply To: Convert Attachments to Gallery

  • You could create an acf/load_field filter or an acf/load_value filter You could then use the WP get_attached_media() function to get all of the media for a post.

    add_filter('acf/load_value/name=your-field-name', 'build_gallery_from_attachments', 10, 3);
    function build_gallery_from_attachments($value, $post_id, $field) {
      if (!empty($value)) {
        // already has a value
      // does not have a value, build value from attachments
      $media = get_attached_media('image', $post_id);
      $value = array();
      if ($media) {
        foreach ($media as $image) {
          $value[] = $image->ID;
      return $value;