For the complete documentation index, see llms.txt. This page is also available as Markdown.

API Rest field integration

API Rest field integration

ACPT comes with custom integration with the standard WordPress API Rest.

Read operations

Suppose you have registered a custom meta field called text for native posts.

Call a GET request to the endpoint:

/wp-json/wp/v2/posts

Inside the post objects, you'll find the node called acpt:

{
   "id":2274,
   "date":"2022-02-22T12:46:10",
   "date_gmt":"2022-02-22T12:46:10",
   "guid":{
      "rendered":"http://localhost:83/?p=2274"
   },
   "modified":"2022-02-22T13:00:09",
   "modified_gmt":"2022-02-22T13:00:09",
   "slug":"ciao",
   "status":"publish",
   "type":"post",
   "link":"http://localhost:83/ciao/",
   "title":{
      "rendered":"Ciao"
   },
   "content":{
      "rendered":"\n<p>lorem ispum</p>\n",
      "protected":false
   },
   "excerpt":{
      "rendered":"<p>lorem ispum</p>\n",
      "protected":false
   },
   "author":1,
   "featured_media":0,
   "comment_status":"open",
   "ping_status":"open",
   "sticky":false,
   "template":"",
   "format":"standard",
   "meta":[

   ],
   "category":[
      47
   ],
   "post_tag":[

   ],
   "other":[

   ],
   "acpt":{
      "meta":[
         {
            "meta_box":"info",
            "meta_fields":[
               {
                  "name":"text",
                  "type":"Text",
                  "options":[

                  ],
                  "value":"",
                  "default":"",
                  "required":false,
                  "showInAdmin":false
               }
            ]
         }
      ]
   },
   "_links":{}
}

If you have installed WooCommerce try to call:

in this case the acpt object contains also a key called wc_product_data, an array of field objects:

Write operations

To write field data via API, make a POST request to the same endpoint:

/wp-json/wp/v2/posts

You have to add acpt node to the usual JSON payload.

Suppose you want to create a new post with the title "Lorem ipsum":

Please note that some fields require the value to be an array.

For example, suppose you have a select multiple field called select within a meta box called info:

Last updated