-
Notifications
You must be signed in to change notification settings - Fork 122
Fill in PHP field registration in README #186
Comments
I second this. I'm trying to figure out how add PHP-produced ACF fields to the GraphQL. If anyone can point me in the right direction, I'd be happy to write up the README once I figure it out. |
In the issue I link below it's mentioned that this is currently under development. However it appears you need to add an entry However I haven't tested that yet |
Please see the following code snippet that worked for me. acf_add_local_field_group(array(
'key' => 'test_group',
'title' => 'test_group',
'fields' => array(
array(
'key' => 'test_field,
'label' => 'test_field',
'name' => 'test_field',
'type' => 'text',
'show_in_graphql' => 1,
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'post',
),
),
),
'show_in_graphql' => 1,
'graphql_field_name' => 'testfield',
)); |
@arnespremberg the concern was not that I couldn't get this approach working, but that this was not documented in the README to prevent having to essentially reverse engineer the plugin in order to understand how to surface fields correctly. |
@wdews Oh, and by the way, there was another person in this issue that seemed to struggle with finding the right option. |
I'm gonna fiddle with it this afternoon (or potentially into tomorrow) to confirm it works and I'll put in a PR with the update. It occurs to me my issue was more along the lines of custom post types, but those CPTs did have custom fields. Honestly they seemed to work pretty much out of the box, but I'm setting up an instance from scratch to confirm. |
Closed by #235 |
In the readme.md file, the section titled Registering Fields in PHP trails off with a
@todo
annotation.Could somebody please fill in this section?
The text was updated successfully, but these errors were encountered: