Skip to content Skip to sidebar Skip to footer

Populate Acf Fields Using Wordpress Rest Api Js

I'm new working with WordPress and I'm playing around with the Advanced Custom Fields plugin. It seems nice but I'd like to know if it's possible to POST a new object (created usin

Solution 1:

Like the GET request, You can use the POST request as well to store data into the CMS. What you need to do is to pass the authorization headers with the POST API call. You can get more detail about the authorization mechanism here: https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/

Headers:

Authorization:Bearer <token>Content-Type:application/json

Secondly you can pass the Body data as a RAW json as below:

{"title":"Sample ACF field demo","status":"publish","fields":{"text_custom_field_name":"Text value","checkbox_custom_field_name":["Option1,","Option2,","Option3"],"textarea_custom_field_name":"This is message field","boolean_custom_field_name":[true]}}

Please let me know if any help needed.

Thanks

Solution 2:

TL;DR - ACF now has support for the WP REST API

Hey all, Iain the Product Manager for Advanced Custom Fields here 👋

As part of the ACF 5.11 release we added native support for ACF fields in the WordPress REST API. Read more about that here.

Post a Comment for "Populate Acf Fields Using Wordpress Rest Api Js"