-
Notifications
You must be signed in to change notification settings - Fork 132
-
Greetings!
I can't figure out how to use custom fields from ACF on the page?
I created a custom field with the text type, checked "Show in GraphQL", filled in the field on the page, but nothing similar appeared in the page props.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 1 reply
-
Sorry for contacting you directly, but I can't find a solution :((
Beta Was this translation helpful? Give feedback.
All reactions
-
@AeShevch Sorry for the late reply! Have you added the ACF fields to your query?
For example, if I have a field group that's set to show on pages:
screen-capture 2022年04月29日 at 15 54 27
Your GraphQL query for page routes should look something like this:
query PageByID {
pageBy(pageId: 383) {
id
slug
theCustomFieldName {
aField
}
}
}
The result should look something like this:
{
"data": {
"pageBy": {
"id": "cG9zdDozODM=",
"slug": "home",
"theCustomFieldName": {
"aField": "This is the custom field!"
}
}
},
...
}
Beta Was this translation helpful? Give feedback.