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

Button Group

ACF
Last Upated: Tuesday, Jan 23, 2024

button_group

The Button Group field type is native to ACF (free) and provides users with the option to select a choice from a group of buttons.

Resolve Type

Fields of the "button_group" field type resolve to "String" in the GraphQL Schema, even if the choices are numbers or boolean values.

Field Settings

Below you will find information about how various ACF field settings can impact how the field will map to the GraphQL Schema and/or modify resolution of the field when queried.

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 button_group",
"show_in_graphql": 1,
"graphql_field_name": "myFieldGroupWithButtonGroup",
"map_graphql_types_from_location_rules": 0,
"graphql_types": [
"Page"
],
"fields": [
{
"key": "my_field_",
"label": "My Field",
"name": "my_field",
"type": "button_group",
"show_in_graphql": 1,
"graphql_field_name": "myFieldWithButtonGroup"
}
],
"location": [
[
{
"param": "post_type",
"operator": "==",
"value": "page"
}
]
]
}
]
);
});

Querying the Button Group Field

Previous
Button