Support

Account

Home Forums Backend Issues (wp-admin) ACF load_value to Gallery Field Reply To: ACF load_value to Gallery Field

  • So, for some reason the json that is stored in the DB is being partially decoded, which is odd.

    This value in the DB is obviously a json srting

    
    [{"title":"Slider 47","image":{"attachment_id":"1653"}},{"title":"Image-1","image":{"attachment_id":"1652"}},{"title":"Image-2","image":{"attachment_id":"1651"}},{"title":"Image-3","image":{"attachment_id":"1650"}},{"title":"Image-4","image":{"attachment_id":"1649"}},{"title":"Image-5","image":{"attachment_id":"1648"}}]
    

    But I don’t know why your query would be returning the decoded value or why the value of the slides index would appear to still be a json value.

    You might want to try

    
    foreach ($slider_data as $slide) {
      $attachments = json_decode($slide['slides'], true);
      if ($attachments) {
        foreach ($attachments as $attachment) {
          $value = $attachment['attachment_id'];
        }
      }
    }