Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

How to query ACF Field of the "Group" type? #102

Closed
jasonbahl opened this issue Dec 13, 2019 · 3 comments
Closed

How to query ACF Field of the "Group" type? #102

jasonbahl opened this issue Dec 13, 2019 · 3 comments
Assignees

Comments

@jasonbahl
Copy link
Contributor

Originally asked by @amreshabux on the main WPGraphQL repo: wp-graphql/wp-graphql#1079

Hey!

Are you using the WPGraphQL for ACF plugin?

If so, make sure to set the field group to show_in_graphql => true and provide a graphql_field_name.

For example, I created a Field Group called "Group Test" and I registered a "Group" field (also named "Group Test"):

Screen Shot 2019-12-13 at 9 52 20 AM

And I made sure to set the group to show_in_graphql => true and I provided the field name groupTest.

Screen Shot 2019-12-13 at 9 52 10 AM

Since the group is assigned to the post_type => post location, the groupTest field will now be available in the Schema on the Post Type.

I have a Group field registered, also named Group Test and in that Group field I added a text field, cleverly named "text".

I created a Post and saved a value within the "text" field.

Screen Shot 2019-12-13 at 9 52 36 AM

I can now query for that "text" field on the "group" field like so:

Screen Shot 2019-12-13 at 9 53 14 AM

@Technicode
Copy link

Hey Jason,

I'm in the process of passing data from an existing WordPress installation to Gridsome and have had a bit of trouble exposing the Field Group to the WPGraphQL Schema. If I declare the Post Type value along with an additional condition (in my case Page Template) under Location the Field Group isn't exposed in the schema.

image

I've tested it with just setting post_type => page without any other conditions and then the data is exposed properly. Seems like a bug as I don't want to show it on any page unless the correct template is selected.

Any work around that I could add to my functions.php file as a fix?

I am loving this plugin! Please keep up the hard work for a 1.0.0 release 🙌

@vollervidez
Copy link

vollervidez commented Aug 18, 2020

Hello @Technicode this is a known "issue" with ACF location rules please reference this post for more information #135 .

If you are looking for a quick workaround refer to this post #134 . I am using this particular workaround at the moment for a page builder feature i'm implementing. Be advised that the latest ACF Pro update 5.9.0 caused this work around to fail for me so I reverted ACF Pro back to 5.8.9

@AbeCole
Copy link

AbeCole commented Sep 14, 2020

Hello @Technicode this is a known "issue" with ACF location rules please reference this post for more information #135 .

If you are looking for a quick workaround refer to this post #134 . I am using this particular workaround at the moment for a page builder feature i'm implementing. Be advised that the latest ACF Pro update 5.9.0 caused this work around to fail for me so I reverted ACF Pro back to 5.8.9

I havn't tried with ACT Pro 5.8.9 but from my understanding there shouldn't be any reason for the work around to break, unless wp-graphql-acf has generally broken because of the changes made to ACT Pro.

Just tested that workaround on 5.9.1 and seems to be working fine, if you do still have an error/issue please post it in that other thread and I will take a look when i have time

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants