Saturday, 8 June 2019

How to include META fields in Wordpress API Post?

I am using Wordpress version 5.2.1 which means I am not using a plugin for the WP API. I have working code which creates a new post (using a custom post type) on my WP site, all good there. The problem is that i've created custom fields using ACF, but they're not appearing in the newly created post. The following is an example of what I am sending to WP via: /wp-json/wp/v2/experience.

Note: experience is my custom post type.

{'title': 'test', 'content': 'testing from python', 'status': 'draft', 'author': 1, 'meta': {'location': 'NYC', 'date': 'never', 'event_url': 'http://google.com'}, 'featured_media': 1221}

This creates a post, but the fields inside of meta are completely ignored. My goal is to have the fields I specify in meta be included in my newly created post .

I have tried the solutions listed at the following URLs and nothing has worked.

https://gist.github.com/rileypaulsen/9b4505cdd0ac88d5ef51

Wordpress Rest API - Custom Fields

https://jeffreyeverhart.com/2017/06/14/adding-custom-fields-wordpress-json-api/

What am I missing?



from How to include META fields in Wordpress API Post?

No comments:

Post a Comment