{"id":13466836,"url":"https://github.com/wp-graphql/wp-graphql-acf","last_synced_at":"2025-03-26T00:31:31.629Z","repository":{"id":38325388,"uuid":"183248851","full_name":"wp-graphql/wp-graphql-acf","owner":"wp-graphql","description":"WPGraphQL for Advanced Custom Fields","archived":true,"fork":false,"pushed_at":"2024-07-22T18:04:14.000Z","size":5108,"stargazers_count":626,"open_issues_count":24,"forks_count":123,"subscribers_count":24,"default_branch":"develop","last_synced_at":"2024-10-29T20:33:27.751Z","etag":null,"topics":["advanced-custom-fields","api","graphql","hacktoberfest","wordpress","wpgraphql"],"latest_commit_sha":null,"homepage":"https://wpgraphql.com/acf","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wp-graphql.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-24T14:44:26.000Z","updated_at":"2024-09-29T11:23:32.000Z","dependencies_parsed_at":"2024-01-05T05:02:33.833Z","dependency_job_id":"75d1b87e-45e0-4ee8-a4aa-407658a16186","html_url":"https://github.com/wp-graphql/wp-graphql-acf","commit_stats":{"total_commits":200,"total_committers":31,"mean_commits":6.451612903225806,"dds":"0.43999999999999995","last_synced_commit":"665d3f6ebb0364dacf81be57a80838dd0df87189"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-graphql%2Fwp-graphql-acf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-graphql%2Fwp-graphql-acf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-graphql%2Fwp-graphql-acf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-graphql%2Fwp-graphql-acf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wp-graphql","download_url":"https://codeload.github.com/wp-graphql/wp-graphql-acf/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238009002,"owners_count":19401345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["advanced-custom-fields","api","graphql","hacktoberfest","wordpress","wpgraphql"],"created_at":"2024-07-31T15:00:50.571Z","updated_at":"2025-03-26T00:31:31.588Z","avatar_url":"https://github.com/wp-graphql.png","language":"PHP","funding_links":[],"categories":["Plugins","PHP","HTML","Plugins \u0026 Tools"],"sub_categories":["WordPress"],"readme":"# WPGraphQL for Advanced Custom Fields\n\n----\n\n🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨\n\nThis plugin has gone through a complete re-architecture and this repository will soon be archived. \n\nWe recommend you upgrade to the new WPGraphQL for ACF v2.0+ at your earliest convenience. \n\nThe new version contains breaking changes, so update with caution. Below are some resources to help:\n\n- UPGRADE GUIDE: https://acf.wpgraphql.com/upgrade-guide\n- NEW PLUGIN REPO: https://github.com/wp-graphql/wpgraphql-acf\n- NEW PLUGIN ON WORDPRESS.ORG: https://wordpress.org/plugins/wpgraphql-acf\n- NEW PLUGIN ON COMPOSER: https://packagist.org/packages/wp-graphql/wpgraphql-acf\n- NEW PLUGIN ON WPPACKAGIST: https://wpackagist.org/search?q=wpgraphql-acf\u0026type=any\u0026search=\n\n🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨\n----\n\nWPGraphQL for Advanced Custom Fields automatically exposes your ACF fields to the WPGraphQL Schema.\n\n- [Install and Activate](#install-and-activate)\n  - [Installing from Github](#install-from-github)\n  - [Installing with Composer](#install-with-composer)\n- [Dependencies](#dependencies)\n- [Adding Fields to the WPGraphQL Schema](#adding-fields-to-wpgraphql)\n- [Supported Fields](#supported-fields)\n  - [Accordion](./docs/fields/accordion.md)\n  - [Button Group](./docs/fields/button-group.md)\n  - [Checkbox](./docs/fields/checkbox.md)\n  - [Clone](./docs/fields/clone.md)\n  - [Color Picker](./docs/fields/color-picker.md)\n  - [Date Picker](./docs/fields/date-picker.md)\n  - [Date/Time Picker](./docs/fields/date-time-picker.md)\n  - [Email](./docs/fields/email.md)\n  - [File](./docs/fields/file.md)\n  - [Flexible Content](./docs/fields/flexible-content.md)\n  - [Gallery](./docs/fields/gallery.md)\n  - [Google Map](./docs/fields/google-map.md)\n  - [Group](./docs/fields/group.md)\n  - [Image](./docs/fields/image.md)\n  - [Link](./docs/fields/link.md)\n  - [Message](./docs/fields/message.md)\n  - [Number](./docs/fields/number.md)\n  - [Oembed](./docs/fields/oembed.md)\n  - [Page Link](./docs/fields/page-link.md)\n  - [Password](./docs/fields/password.md)\n  - [Post Object](./docs/fields/post-object.md)\n  - [Radio](./docs/fields/radio.md)\n  - [Range](./docs/fields/range.md)\n  - [Relationship](./docs/fields/relationship.md)\n  - [Repeater](./docs/fields/repeater.md)\n  - [Select](./docs/fields/select.md)\n  - [Tab](./docs/fields/tab.md)\n  - [Taxonomy](./docs/fields/taxonomy.md)\n  - [Text](./docs/fields/text.md)\n  - [Text Area](./docs/fields/text-area.md)\n  - [Time Picker](./docs/fields/time-picker.md)\n  - [True/False](./docs/fields/true-false.md)\n  - [Url](./docs/fields/url.md)\n  - [User](./docs/fields/user.md)\n  - [WYSIWYG](./docs/fields/wysiwyg.md)\n- [Options Pages](#options-pages)\n- [Location Rules](#location-rules)\n\n## Install and Activate \u003ca name=\"install-and-activate\" /\u003e\n\nWPGraphQL for Advanced Custom Fields is not currently available on the WordPress.org repository, so you must download it from Github, or Composer.\n\n### Installing From Github \u003ca name=\"install-from-github\" /\u003e\n\nTo install the plugin from Github, you can [download the latest release zip file](https://github.com/wp-graphql/wp-graphql-acf/archive/master.zip), upload the Zip file to your WordPress install, and activate the plugin.\n\n[Click here](https://wordpress.org/support/article/managing-plugins/) to learn more about installing WordPress plugins from a Zip file.\n\n### Installing from Composer \u003ca name=\"install-with-composer\" /\u003e\n\n`composer require wp-graphql/wp-graphql-acf`\n\n## Dependencies \u003ca name=\"dependencies\" /\u003e\n\nIn order to use WPGraphQL for Advanced Custom Fields, you must have [WPGraphQL](https://github.com/wp-graphql/wp-graphql) and [Advanced Custom Fields](https://advancedcustomfields.com) (free or pro) installed and activated.\n\n## Adding Fields to the WPGraphQL Schema \u003ca name=\"adding-fields-to-wpgraphql\" /\u003e\n\n**TL;DR:** [Here's a video](https://www.youtube.com/watch?v=rIg4MHc8elg) showing an overview of usage.\n\nAdvanced Custom Fields, or ACF for short, enables users to add Field Groups, either using a [Graphical User Interface](https://www.advancedcustomfields.com/resources/creating-a-field-group/), [PHP code](https://www.advancedcustomfields.com/resources/register-fields-via-php/), or [local JSON](https://www.advancedcustomfields.com/resources/local-json/) to various screens in the WordPress dashboard, such as (but not limited to) the Edit Post, Edit User and Edit Term screens.\n\nWhatever method you use to register ACF fields to your WordPress site should work with WPGraphQL for Advanced Custom Fields. For the sake of simplicity, the documentation below will _primarily_ use the Graphic User Interface for examples.\n\n### Add ACF Fields to the WPGraphQL Schema\n\nThe first step in using Advanced Custom Fields with WPGraphQL is to [create an ACF Field Group](https://www.advancedcustomfields.com/resources/creating-a-field-group/).\n\nBy default, field groups are _not_ exposed to WPGraphQL. You must opt-in to expose your ACF Field Groups and fields to the WPGraphQL Schema as some information managed by your ACF fields may not be intended for exposure in a queryable API like WPGraphQL.\n\n#### Show in GraphQL Setting\n\nTo have your ACF Field Group show in the WPGraphQL Schema, you need to configure the Field Group to \"Show in GraphQL\".\n\n##### Using the ACF GUI\n\nWhen using the ACF Graphic User Interface for creating fields, WPGraphQL for Advanced Custom Fields adds a **Show in GraphQL** field to Field Groups.\n\nSetting the value of this field to \"Yes\" will show the field group in the WPGraphQL Schema, if a [GraphQL Field Name](#graphql-field-name) is also set\n\n![Show in GraphQL Setting for ACF Field Groups](https://github.com/wp-graphql/wp-graphql-acf/blob/master/docs/img/field-group-show-in-graphql.png?raw=true)\n\n##### Registering Fields in PHP\n\nWhen registering ACF Fields in PHP, you need to add `show_in_graphql` and `graphql_field_name` when defining your field group.  See below as an example.\n\n```php\nfunction my_acf_add_local_field_groups() {\n\n\tacf_add_local_field_group(array(\n\t\t'key' =\u003e 'group_1',\n        'title' =\u003e 'My Group',\n        'show_in_graphql' =\u003e true,\n        'graphql_field_name' =\u003e 'myGroup',\n\t\t'fields' =\u003e array (\n\t\t\tarray (\n\t\t\t\t'key' =\u003e 'field_1',\n\t\t\t\t'label' =\u003e 'Sub Title',\n\t\t\t\t'name' =\u003e 'sub_title',\n\t\t\t\t'type' =\u003e 'text',\n\t\t\t)\n\t\t),\n\t\t'location' =\u003e array (\n\t\t\tarray (\n\t\t\t\tarray (\n\t\t\t\t\t'param' =\u003e 'post_type',\n\t\t\t\t\t'operator' =\u003e '==',\n\t\t\t\t\t'value' =\u003e 'post',\n\t\t\t\t),\n\t\t\t),\n\t\t),\n\t));\n\n}\n\nadd_action('acf/init', 'my_acf_add_local_field_groups');\n```\n\nEach individual field will inherit its GraphQL name from the supplied `name` tag. In this example, `sub_title` will become `subTitle` when requested through GraphQL. If you want more granular control, you can pass `graphql_field_name` to each individual field as well.\n\n## Supported Fields\n\nIn order to document interacting with the fields in GraphQL, an example field group has been created with one field of each type.\n\nTo replicate the same field group documented here you can download the [example field group](https://github.com/wp-graphql/wp-graphql-acf/blob/master/docs/field-group-examples-export.json) and [import it](https://support.advancedcustomfields.com/forums/topic/importing-exporting-acf-settings/) into your environment.\n\nFor the sake of documentation, this example field group has the [location rule](#location-rules) set to \"Post Type is equal to Post\", which will allow for the fields to be entered when creating and editing Posts in the WordPress dashboard, and will expose the fields to the `Post` type in the WPGraphQL Schema.\n\n![Location rule set to Post Type is equal to Post](https://github.com/wp-graphql/wp-graphql-acf/blob/master/docs/img/location-rule-post-type-post.png?raw=true)\n\n## Options Pages\n\n**Reference**: https://www.advancedcustomfields.com/add-ons/options-page/\n\nTo add an option page and expose it to the graphql schema, simply add 'show_in_graphql' =\u003e true when you register an option page.\n\n**Example Usage**\n\n```php\nfunction register_acf_options_pages() {\n\n    // check function exists\n    if ( ! function_exists( 'acf_add_options_page' ) ) {\n        return;\n    }\n\n    // register options page\n    $my_options_page = acf_add_options_page(\n        array(\n            'page_title'      =\u003e __( 'My Options Page' ),\n            'menu_title'      =\u003e __( 'My Options Page' ),\n            'menu_slug'       =\u003e 'my-options-page',\n            'capability'      =\u003e 'edit_posts',\n            'show_in_graphql' =\u003e true,\n        )\n    );\n}\n\nadd_action( 'acf/init', 'register_acf_options_pages' )\nExample Query\nquery GetMyOptionsPage {\n    myOptionsPage {\n        someCustomField\n    }\n}\n```\n\nAlternatively, it's you can check the Fields API Reference to learn about exposing your custom fields to the Schema.\n\n## Location Rules \u003ca name=\"location-rules\" /\u003e\n\nAdvanced Custom Fields field groups are added to the WordPress dashboard by being assigned \"Location Rules\".\n\nWPGraphQL for Advanced Custom Fields uses the Location Rules to determine where in the GraphQL Schema the field groups/fields should be added to the Schema.\n\nFor example, if a Field Group were assigned to \"Post Type is equal to Post\", then the field group would show in the WPGraphQL Schema on the `Post` type, allowing you to query for ACF fields of the Post, anywhere you can interact with the `Post` type in the Schema.\n\n### Supported Locations\n\n@todo: Document supported location rules and how they map from ACF to the WPGraphQL Schema\n\n### Why aren't all location rules supported?\n\nYou might notice that some location rules don't add fields to the Schema. This is because some location rules are based on context that doesn't exist when the GraphQL Schema is generated.\n\nFor example, if you have a location rule to show a field group only on a specific page, how would that be exposed the the Schema? There's no Type in the Schema for just one specific page.\n\nIf you're not seeing a field group in the Schema, look at the location rules, and think about _how_ the field group would be added to a Schema that isn't aware of context like which admin page you're on, what category a Post is assigned to, etc.\n\nIf you have ideas on how these specific contextual rules should be handled in WPGraphQL, submit an issue so we can consider how to best support it!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwp-graphql%2Fwp-graphql-acf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwp-graphql%2Fwp-graphql-acf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwp-graphql%2Fwp-graphql-acf/lists"}