ACF Photo Gallery Field


A lightweight extension of Advanced Custom Field (ACF) that adds Photo Gallery field to any post/pages on your WordPress website.

  • Visually create your Fields
  • Add multiple photos and you can also modify title, caption and link to anything
  • Assign your fields to multiple edit pages (via custom location rules)
  • Easily load data through a simple and friendly API
  • Uses the native WordPress custom post type for ease of use and fast processing
  • Uses the native WordPress metadata for ease of use and fast processing
  • Supports WordPress classic and Gutenberg editor
  • Supports Elementor (support for bricks builder coming soon)


This plugin is a better alternative to ACF Gallery Pro. You need to have knowledge of coding because editing your WordPress theme source code is required. If you’re looking for prebuilt galleries and shortcodes, then this plugin is NOT for you. This plugin will give you a PHP array of images, and you’ll need to create the gallery layout yourself.


Navneil Naicker is the sole developer working on this free WordPress Plugin in his leisure time. He would like to integrate it with premium plugins like Elementor Pro and Advanced Custom Fields Pro. Please donate to support Navneil in continuing further development of this plugin. Click on the link “” to donate.


acf_photo_gallery is a helper function that takes in ACF_FIELD_NAME and POST_ID will query the database and compile the images for you. The output of this function will be an array.

acf_photo_gallery(ACF_FIELD_NAME, POST_ID);


The following example is using Twitter Bootstrap framework to layout. You can use any framework of your choice.

    //Get the images ids from the post_metadata
    $images = acf_photo_gallery('vacation_photos', $post->ID);
    //Check if return array has anything in it
    if( count($images) ):
        //Cool, we got some data so now let's loop over it
        foreach($images as $image):
            $id = $image['id']; // The attachment id of the media
            $title = $image['title']; //The title
            $caption= $image['caption']; //The caption
            $full_image_url= $image['full_image_url']; //Full size image url
            $full_image_url = acf_photo_gallery_resize_image($full_image_url, 262, 160); //Resized size to 262px width by 160px height image url
            $thumbnail_image_url= $image['thumbnail_image_url']; //Get the thumbnail size image url 150px by 150px
            $url= $image['url']; //Goto any link when clicked
            $target= $image['target']; //Open normal or new tab
            $alt = get_field('photo_gallery_alt', $id); //Get the alt which is a extra field (See below how to add extra fields)
            $class = get_field('photo_gallery_class', $id); //Get the class which is a extra field (See below how to add extra fields)
<div class="col-xs-6 col-md-3">
    <div class="thumbnail">
        <?php if( !empty($url) ){ ?><a href="<?php echo $url; ?>" <?php echo ($target == 'true' )? 'target="_blank"': ''; ?>><?php } ?>
            <img src="<?php echo $full_image_url; ?>" alt="<?php echo $title; ?>" title="<?php echo $title; ?>">
        <?php if( !empty($url) ){ ?></a><?php } ?>
<?php endforeach; endif; ?>

Add Extra Fields

To add extra fields add the following to your themes functions.php file.

//Create extra fields called Altnative Text and Status
function my_extra_gallery_fields( $args, $attachment_id, $acf_key ){
    $args['alt'] = array(
        'type' => 'text', 
        'label' => 'Altnative Text', 
        'name' => 'alt', 
        'value' => get_field($field . '_alt', $attachment_id)
    $args['status'] = array(
        'type' => 'select', 
        'label' => 'Status', 
        'name' => 'status', 
        'value' => array(
                '1' => 'Active',
                 '2' => 'Inactive'
            get_field($field . '_status', $attachment_id)
    return $args;
add_filter( 'acf_photo_gallery_image_fields', 'my_extra_gallery_fields', 10, 3 );

Supported field types:
* text, date, color, datetime-local, email, number, tel, time, url, week, range, checkbox, radio, textarea, select

How to get values of extra fields

You can use ACF helper function get_field

get_field('photo_gallery_alt', $id);
get_field('photo_gallery_class', $id);

Pull caption from attachment caption field

By default the caption is being pulled from description field. Add the following filter to your function.php to pull the caption from attachment caption field.

add_filter( 'acf_photo_gallery_caption_from_attachment', '__return_true' );


Send HTTP Request to URL to get JSON response of all posts


Send HTTP Request to URL to get JSON response of specific post


When you receive the response, see the ACF item which contains ACF photo gallery name and array of images.

Installation and basic usage tutorial

ACF Photo Gallery Field on WordPress Custom Post Type tutorial

How to use Elementor dynamic tags with ACF Photo Gallery Field plugin tutorial


This ACF field type is compatible with: ACF 4, 5 and 6


Just like any other WordPress plugin, this plugin can also cause issues with other themes and plugins. If you are facing issues making this plugin work on your WordPress site, please do ask for help in the support forum. This way we can help you out and prevent this issue from happening to someone else. If you want to talk to me directly, you can contact me via my website


From your WordPress dashboard

  1. Visit Plugins > Add New
  2. Search for “ACF Photo Gallery Field”
  3. Install and Activate ACF Photo Gallery Field from your Plugins page
  4. Watch the tutorial to get started


13 ខែ​ឧសភា, 2024 4 replies
Does not work inside ACF fields groups. Simply does not saving any selected images. Also, if a lot images was added, sometimes spontaneously losing all of them when saving the post. Updated 05.13.2024. Changed rating to 1 star. Details below.
26 ខែ​វិច្ឆិកា, 2022
excellent plugin does just what it says it does. check out my quick and dirty shortcode implementation for it on wpcodebin .com/code/443bp5
21 ខែ​សីហា, 2022
Not sure what other people are doing but this worked perfectly for me going into the Elementor image carousel widget. Thanks to the developer
22 ខែ​កក្កដា, 2022
It seems a very good alternative for the official Gallery-Field from ACF. But after many tries, I couldn’t get it to work with the WPGraphQL plugin.
Read all 28 reviews

Contributors & Developers

“ACF Photo Gallery Field” is open source software. The following people have contributed to this plugin.



* [Fixed] URL and target not saving into the database.

* [Fixed] On image edit, popup modal not accessible on Gutenberg editor.

* [Fixed] Undefined array key “nonce”.

* [Fixed] Tidy up few things.

* [Fixed] When click on “Add Images”, WordPress media library not opening.

* [Fixed] Elementor dynamic tag offset index
* [Added] fallback for Elementor dynamic tag for versions prior to 3.16

* [Fixed] Undefined array key “option” error

* [Fixed] renamed a function to avoid conflict.

* [Fixed] Elementor Pro dynamic tag fix. Thanks to GitHub @rloes for the fix.
* [Added] Donation request popup. People gonna hate me for this. Sorry.

* [Fixed] explode(): Passing null to parameter error
* [Fixed] /wp-json/ not showing gallery images on custom post type. Thanks to GitHub @nykula for the fix.

* [Removed] Removed functionality from profile
* [Removed] errors and deprecating warnings

* [Added] Donation link because I’m poor
* [Removed] errors and deprecating warnings

* [Updated] Renamed function from ‘my_profile_update’ to ‘apg_profile_update’
* [Bugfix] Backdrop not going away when the “Native” model is closed
* [Removed] SweetAlert and added native browser alert

* [Added] Support for ACF 6

* [Bugfix] Elementor Pro gallery images preview
* [Added] Support for user profile

* [Bugfix] Sanitizing and escaping inputs

* [Bugfix] Sanitizing and escaping inputs

* [Bugfix] Sanitizing and escaping inputs

* [Bugfix] Security issue and reset body overflow

* [Bugfix] Security issue

* [Bugfix] Remove edit and delete image button conditions

* [Bugfix] Illegal string offset error

* [Bugfix] ElementorPro class not found
* [Bugfix] Warning: Undefined array key “acf-photo-gallery-field”

* [Add] Option for to show/hide edit and remove button
* [Add] Support for Elementor

* [Bugfix] Make gallery images limit optional

* [Removed] Support to ACF get_field() function due to bug

* [Add] Added support to ACF get_field() function
* [Add] Added more fields types to extra fields
* [Add] Added in SweetAlert and images limit options
* [Add] Added message that ACF Photo Gallery isn’t supported on taxonomy

* [Bugfix] Remove not empty condition from checkbox item on edit
* [Remove] Remove support for ACF to REST API plugin
* [Add] Native support for REST API

* [Bugfix] JavaScript error in the console when removing images from the WordPress metabox

* [Added] Support for ACF 5
* [Added] Edit gallery with built-in or WordPress native model. Thanks to Github @makepost
* [Added] Under the hood improvements of the codebase
* [Added] Support for RESTFul API with ACF to REST API plugin

* [Bugfix] Keep data synced with the attachment data
* [Bugfix] Pull caption attachment caption using add filters
* [Bugfix] PHP 7.2 count() error

* [Bugfix] Edit image box disappears on click of pencil edit button reported by @rickytoof9

* [Bugfix] Error on saving post with empty gallery. Patch provided by @ugy
* [Bugfix] Showing multiple photo gallery fields in the same page reported by @rickytoof9
* [Added] Support for srcset. Special thanks to @ugy for the code


  • [Added] Support for SVG
  • [Added] Support for legacy PHP version
  • [Added] Add extra fields


  • [Added] Can sortable gallery images
  • [Bugfix] Fixed the order to follow the sort order for gallery images


  • Change the meta_key from acf field_key to acf field_name
  • [Added] Helper function acf_photo_gallery() to pull images
  • [Added] Helper function acf_photo_gallery_resize_image to resize the image on fly and save it
  • [Bugfix] Issue with target parameter in config
  • [Bugfix] Issue with url not saving properly


  • [Bugfix] Support for WordPress 4.6
  • [Added] Some changes on on the display
  • [Added] Fetch the data from the database


  • [Bugfix] Undefined index: acf-photo-gallery-field on file acf-photo_gallery-v4
  • [Bugfix] When delete the photos from the gallery, the last photo was not deleting
  • [Bugfix] Gallery photos was not saving in the database


  • Initial Release.