Populate ACF Fields using Wordpress Rest API JS

后端 未结 1 1391
南旧
南旧 2020-12-21 22:25

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 possib

相关标签:
1条回答
  • 2020-12-21 22:56

    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

    0 讨论(0)
提交回复
热议问题