Site docs are currently being updated 🚧 Thank you for your patience! 🙏

Gallery

ACF Pro
Last Upated: Thursday, Feb 1, 2024

gallery

The Gallery field is native to ACF PRO and provides an interactive interface for managing a collection of attachments.

Resolve Type

The "gallery" field type resolves as a "AcfMediaItemConnection" Type in the GraphQL Schema.

This allows for images to be queried as a nodes of the MediaItem Type, where the client can ask for any property of each Image.

Field Settings

Field Configuration

<?php
add_action( 'acf/include_fields', function() {
if ( ! function_exists( 'acf_add_local_field_group' ) ) {
return;
}
acf_add_local_field_group(
[
{
"key": "my_field_group_",
"title": "My Field Group with gallery",
"show_in_graphql": 1,
"graphql_field_name": "myFieldGroupWithGallery",
"map_graphql_types_from_location_rules": 0,
"graphql_types": [
"Page"
],
"fields": [
{
"key": "my_field_",
"label": "My Field",
"name": "my_field",
"type": "gallery",
"show_in_graphql": 1,
"graphql_field_name": "myFieldWithGallery"
}
],
"location": [
[
{
"param": "post_type",
"operator": "==",
"value": "page"
}
]
]
}
]
);
});