{"id":13549425,"url":"https://github.com/airesvsg/acf-to-rest-api","last_synced_at":"2025-04-28T15:42:31.746Z","repository":{"id":43408494,"uuid":"48928504","full_name":"airesvsg/acf-to-rest-api","owner":"airesvsg","description":"Exposes Advanced Custom Fields Endpoints in the WordPress REST API","archived":false,"fork":false,"pushed_at":"2024-12-31T16:15:54.000Z","size":74,"stargazers_count":1340,"open_issues_count":149,"forks_count":114,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-04-12T12:46:31.751Z","etag":null,"topics":["acf","api","custom","fields","rest","rest-api","wordpress","wordpress-plugin","wp","wp-api"],"latest_commit_sha":null,"homepage":"https://wordpress.org/plugins/acf-to-rest-api/","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/airesvsg.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"custom":["https://www.paypal.com/donate?hosted_button_id=P4DVDKW4ZV7GE"]}},"created_at":"2016-01-03T00:20:58.000Z","updated_at":"2025-04-12T07:28:19.000Z","dependencies_parsed_at":"2025-01-31T05:31:15.652Z","dependency_job_id":"8a863c1d-0ce6-4265-bfd6-2f6597e70e7f","html_url":"https://github.com/airesvsg/acf-to-rest-api","commit_stats":{"total_commits":51,"total_committers":6,"mean_commits":8.5,"dds":0.0980392156862745,"last_synced_commit":"3bfee8ea454a9831456615516ba772a9664dd048"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airesvsg%2Facf-to-rest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airesvsg%2Facf-to-rest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airesvsg%2Facf-to-rest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airesvsg%2Facf-to-rest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/airesvsg","download_url":"https://codeload.github.com/airesvsg/acf-to-rest-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251340786,"owners_count":21573981,"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":["acf","api","custom","fields","rest","rest-api","wordpress","wordpress-plugin","wp","wp-api"],"created_at":"2024-08-01T12:01:21.755Z","updated_at":"2025-04-28T15:42:31.722Z","avatar_url":"https://github.com/airesvsg.png","language":"PHP","funding_links":["https://www.paypal.com/donate?hosted_button_id=P4DVDKW4ZV7GE"],"categories":["PHP"],"sub_categories":[],"readme":"ACF to REST API\r\n====\r\nExposes [Advanced Custom Fields](https://wordpress.org/plugins/advanced-custom-fields/) Endpoints in the [WordPress REST API](https://developer.wordpress.org/rest-api/)\r\n\r\nhttps://wordpress.org/plugins/acf-to-rest-api/\r\n\r\n- [Installation](#installation)\r\n- [Endpoints](#endpoints)\r\n- [Filters](#filters)\r\n- [Deprecated Filters 🆕](#deprecated-filters)\r\n- [Request API Version 🆕](#request-api-version)\r\n- [Field Settings 🆕](#field-settings)\r\n- [Editing the Fields](#editing-the-fields)\r\n- [Examples](#examples)\r\n- [Get ACF Fields Recursively 🆕](#get-acf-fields-recursively)\r\n- [Cache](#cache)\r\n\r\nInstallation\r\n====\r\n1. Copy the `acf-to-rest-api` folder into your `wp-content/plugins` folder\r\n2. Activate the `ACF to REST API` plugin via the plugin admin page\r\n\r\nEndpoints\r\n====\r\n\r\n| Endpoint | READABLE | EDITABLE |\r\n|----------|:--------:|:--------:|\r\n| /wp-json/acf/v3/posts 🆕 | ✅ | ❌ |\r\n| /wp-json/acf/v3/posts/**{id}** | ✅ | ✅ |\r\n| /wp-json/acf/v3/posts/**{id}**/**{field-name}** | ✅ | ✅ |\r\n| /wp-json/acf/v3/pages 🆕 | ✅ | ❌ |\r\n| /wp-json/acf/v3/pages/**{id}** | ✅ | ✅ |\r\n| /wp-json/acf/v3/pages/**{id}**/**{field-name}** | ✅ | ✅ |\r\n| /wp-json/acf/v3/users 🆕 | ✅ | ❌ |\r\n| /wp-json/acf/v3/users/**{id}** | ✅ | ✅ |\r\n| /wp-json/acf/v3/users/**{id}**/**{field-name}** | ✅ | ✅ |\r\n| /wp-json/acf/v3/**{taxonomy}** 🆕 | ✅ | ❌ |\r\n| /wp-json/acf/v3/**{taxonomy}**/**{id}** 🆕 | ✅ | ✅ |\r\n| /wp-json/acf/v3/**{taxonomy}**/**{id}**/**{field-name}** 🆕 | ✅ | ✅ |\r\n| /wp-json/acf/v3/comments 🆕 | ✅ | ❌ |\r\n| /wp-json/acf/v3/comments/**{id}** | ✅ | ✅ |\r\n| /wp-json/acf/v3/comments/**{id}**/**{field-name}** | ✅ | ✅ |\r\n| /wp-json/acf/v3/media 🆕 | ✅ | ❌ |\r\n| /wp-json/acf/v3/media/**{id}** | ✅ | ✅ |\r\n| /wp-json/acf/v3/media/**{id}**/**{field-name}** | ✅ | ✅ |\r\n| /wp-json/acf/v3/**{post-type}** 🆕 | ✅ | ❌ |\r\n| /wp-json/acf/v3/**{post-type}**/**{id}** 🆕 | ✅ | ✅ |\r\n| /wp-json/acf/v3/**{post-type}**/**{id}**/**{field-name}** 🆕 | ✅ | ✅ |\r\n| /wp-json/acf/v3/options/**{id}** 🆕 | ✅ | ✅ |\r\n| /wp-json/acf/v3/options/**{id}**/**{field-name}** 🆕 | ✅ | ✅ |\r\n\r\nFilters\r\n====\r\n| Filter    | Argument(s) |\r\n|-----------|-----------|\r\n| acf/rest_api/id | mixed ( string, integer, boolean ) **$id**\u003cbr\u003estring **$type** 🆕\u003cbr\u003estring **$controller** 🆕 |\r\n| acf/rest_api/key | string **$key**\u003cbr\u003eWP_REST_Request **$request**\u003cbr\u003estring **$type** |\r\n| acf/rest_api/item_permissions/get | boolean **$permission**\u003cbr\u003eWP_REST_Request **$request**\u003cbr\u003estring **$type** |\r\n| acf/rest_api/item_permissions/update | boolean **$permission**\u003cbr\u003eWP_REST_Request **$request**\u003cbr\u003estring **$type** |\r\n| acf/rest_api/**{type}**/prepare_item | mixed ( array, boolean ) **$item**\u003cbr\u003eWP_REST_Request **$request** |\r\n| acf/rest_api/**{type}**/get_fields | mixed ( array, WP_REST_Request ) **$data**\u003cbr\u003emixed ( WP_REST_Request, NULL ) **$request** |\r\n| acf/rest_api/field_settings/show_in_rest 🆕 | boolean **$show** |\r\n| acf/rest_api/field_settings/edit_in_rest 🆕 | boolean **$edit** |\r\n\r\nBasic example of how to use the filters, in this case I will set a new permission to get the fields\r\n```PHP\r\nadd_filter( 'acf/rest_api/item_permissions/get', function( $permission ) {\r\n  return current_user_can( 'edit_posts' );\r\n} );\r\n```\r\n\r\nDeprecated filters\r\n====\r\n| Filter    | Argument(s) |\r\n|-----------|-----------|\r\n| acf/rest_api/type | string **$type** |\r\n| acf/rest_api/types | array **$types** |\r\n| acf/rest_api/default_rest_base | boolean **$default**\u003cbr\u003estring **$type** |\r\n\r\nRequest API version\r\n====\r\nSee below how to select the Request API Version.\r\n\r\n1. Open the plugins page;\r\n2. Click the settings link under the pluing name ( `ACF to REST API` );\r\n3. Select your version in the `ACF to REST API` session;\r\n4. Click in the button Save changes.\r\n\r\nThe other alternative is to define the constant `ACF_TO_REST_API_REQUEST_VERSION` in your `wp-config.php`\r\n\r\n```PHP\r\ndefine( 'ACF_TO_REST_API_REQUEST_VERSION', 2 );\r\n```\r\n\r\nField Settings\r\n====\r\nIn this version is possible to configure the field options via admin.\r\n\r\nThe options are enabled using the filters below, by default theses options are disabled.\r\n\r\n```PHP\r\n// Enable the option show in rest\r\nadd_filter( 'acf/rest_api/field_settings/show_in_rest', '__return_true' );\r\n\r\n// Enable the option edit in rest\r\nadd_filter( 'acf/rest_api/field_settings/edit_in_rest', '__return_true' );\r\n```\r\n\r\nEditing the fields\r\n====\r\nThe fields should be sent into the key `fields`.\r\n\r\n**Action:** http://localhost/wp-json/acf/v3/posts/1\r\n\r\n```HTML\r\n\u003cform action=\"http://localhost/wp-json/acf/v3/posts/1\" method=\"POST\"\u003e\r\n  \u003c?php \r\n    // https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/\r\n    wp_nonce_field( 'wp_rest' ); \r\n  ?\u003e\r\n  \u003clabel\u003eSite: \u003cinput type=\"text\" name=\"fields[site]\"\u003e\u003c/label\u003e\r\n  \u003cbutton type=\"submit\"\u003eSave\u003c/button\u003e\r\n\u003c/form\u003e\r\n```\r\n\r\n**Action:** http://localhost/wp-json/wp/v2/posts/1\r\n\r\n```HTML\r\n\u003cform action=\"http://localhost/wp-json/wp/v2/posts/1\" method=\"POST\"\u003e\r\n  \u003c?php \r\n    // https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/\r\n    wp_nonce_field( 'wp_rest' ); \r\n  ?\u003e\r\n  \u003clabel\u003eTitle: \u003cinput type=\"text\" name=\"title\"\u003e\u003c/label\u003e\r\n  \u003ch3\u003eACF\u003c/h3\u003e\r\n  \u003clabel\u003eSite: \u003cinput type=\"text\" name=\"fields[site]\"\u003e\u003c/label\u003e\r\n  \u003cbutton type=\"submit\"\u003eSave\u003c/button\u003e\r\n\u003c/form\u003e\r\n```\r\n\r\nUse the filter `acf/rest_api/key` to change the key `fields`.\r\n\r\n```PHP\r\nadd_filter( 'acf/rest_api/key', function( $key, $request, $type ) {\r\n  return 'acf_fields';\r\n}, 10, 3 );\r\n```\r\n\r\nNow, the fields should be sent into the key `acf_fields`\r\n\r\n```HTML\r\n\u003cform action=\"http://localhost/wp-json/acf/v3/posts/1\" method=\"POST\"\u003e\r\n  \u003c?php \r\n    // https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/\r\n    wp_nonce_field( 'wp_rest' ); \r\n  ?\u003e\r\n  \u003clabel\u003eSite: \u003cinput type=\"text\" name=\"acf_fields[site]\"\u003e\u003c/label\u003e\r\n  \u003cbutton type=\"submit\"\u003eSave\u003c/button\u003e\r\n\u003c/form\u003e\r\n```\r\n\r\nExamples\r\n====\r\nSample theme to edit the ACF Fields.\r\n\r\nhttps://github.com/airesvsg/acf-to-rest-api-example\r\n\r\nTo-do list 🆕\r\n\r\nhttps://github.com/airesvsg/to-do-list-acf-to-rest-api\r\n\r\n\r\nGet ACF Fields Recursively🆕\r\n====\r\nhttps://github.com/airesvsg/acf-to-rest-api-recursive\r\n\r\nMore details:\r\n\r\n- Issues\r\n  - https://github.com/airesvsg/acf-to-rest-api/issues/109\r\n  - https://github.com/airesvsg/acf-to-rest-api/issues/223\r\n  - https://github.com/airesvsg/acf-to-rest-api/issues/9\r\n\r\n- Pull Request\r\n  - https://github.com/airesvsg/acf-to-rest-api/pull/95\r\n\r\nCache\r\n====\r\nEnable caching for WordPress REST API and increase speed of your application.\r\n\r\nhttps://github.com/airesvsg/wp-rest-api-cache\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairesvsg%2Facf-to-rest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fairesvsg%2Facf-to-rest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairesvsg%2Facf-to-rest-api/lists"}