Ready to get started?Download WordPress


AdvancedCustomFields compatibility for writing / creating posts (1 post)

  1. michapixel
    Posted 1 year ago #

    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.


Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic