AdvancedCustomFields compatibility for writing / creating posts
-
There’s already something going on with the above mentioned plugin in regards to JSON_API, but for those stuck with an old version of ACF (<4) who need to write ACF-fields (eg. i am collecting a json-feed from several sources ) … well i’ve got a dirty solution:
edit the post.php of JSON_API (/models/post.php) ~line 113
if (isset($wp_values['ID'])) { $this->id = wp_update_post($wp_values); } else { $this->id = wp_insert_post($wp_values); } + if (isset($values['fields'])) { + // add custom fields + foreach ($values["fields"] as $metakey => $metavalue) { + update_post_meta($this->id, $metakey, $metavalue); + } + }
that should do the work.
if someone knows a better way to do that, maybe extending the class or something like that, feel free to correct me here.
- The topic ‘AdvancedCustomFields compatibility for writing / creating posts’ is closed to new replies.