Home Forums Add-ons Gallery Field How to extract the serialized array Reply To: How to extract the serialized array

  • If you’re not inside WP then it will be extremely difficult to get what you’re looking for. It’s going to take some additional queries.

    ACF stores only the attachment ID in a serialized array. You will first need to unserialize the array and then you will need to do queries to get the image URL.

    If I was doing this inside of WP I would do something like this.

    $image_array = maybe_unserialize(get_post_meta($post_id, 'gallery_field', true));
    $count = count($image_array);
    for ($i=0; $i<$count; $i++) {
      $image = wp_get_attachment_src($image_array[$i], 'full');
      $image_src = $image[0];

    I am not familiar with exactly how you’d do that with SQL.