Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

how to use custom fields from ACF on the page? #935

Unanswered
AeShevch asked this question in Q&A
Discussion options

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.

Снимок экрана 2022年02月18日 в 1 05 01

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

@itsamoreh

Sorry for contacting you directly, but I can't find a solution :((

You must be logged in to vote
1 reply
Comment options

@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!"
 }
 }
 },
 ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /