wp-api-angular icon indicating copy to clipboard operation
wp-api-angular copied to clipboard

Update with WpApiCustom

Open LAURENS-Damien opened this issue 6 years ago • 0 comments

Hello,

I try to use wpApiCustom for update a custom post whitch use ACF (Advanced Custom Fields). Here are the data to update : {"id":92,"date":"2018-03-07T21:50:46","date_gmt":"2018-03-07T20:50:46","guid":{"rendered":"http://localhost/?post_type=evenements&p=92"},"modified":"2018-04-25T22:21:06","modified_gmt":"2018-04-25T20:21:06","slug":"1er-evenement","status":"publish","type":"evenements","link":"http://localhost/evenements/1er-evenement/","title":{"rendered":"remimartin_adm"},"content":{"rendered":"

Evenement1|08/03/2018</p>\n","protected":false},"template":"","acf":{"id":"1","nom_de_levenement":"Event1","date_de_levenement":"07/03/2018"},"_links":{"self":[{"href":"http://localhost/wp-json/wp/v2/evenements/92"}],"collection":[{"href":"http://localhost/wp-json/wp/v2/evenements"}],"about":[{"href":"http://localhost/wp-json/wp/v2/types/evenements"}],"wp:attachment":[{"href":"http://localhost/wp-json/wp/v2/media?parent=92"}],"curies":[{"name":"wp","href":"https://api.w.org/{rel}","templated":true}]}}

I try to use wpApiCustom like this but it doesn't work : this.eventToUpdate = wpApiCustom.getInstance('evenements').update(92, { "acf" : [{"nom_de_levenement": "newName"}] }) .toPromise() .then(response => response.json()) .catch(error => {});

Is it possible to update an ACF whith wpApiCustom and if yes, what is the correct syntax?

Thanks for your answer.

LAURENS-Damien avatar Apr 25 '18 20:04 LAURENS-Damien