I’m trying to create a new custom post type in WordPress using an Airtable node as a trigger and a HTTP Request to create the custom post type based on the info from Airtable.
All is going well, no error, but some custom fields that are created in WordPress ACF are not populated with data.
All the rest: slug, title, link, status, type(post type) are working fine.
Below is my workflow and a screenshot.
Does anybody have any idea?
This is an issue of WordPress, not n8n, it happens with other CPT types.
First make a POST request with the WP native fields, “title”, “descriptions” to create the the post initially, then make another POST request this time with the POST ID given by the first request but to update the post, and you then need to add ACF fields this way as you need to pass the data as a JSON encoded
"author": "Abraham (Abe) Simpson"
Note - Always worth to check also, if you exposed ACF fields in the REST API
Thanks! I did found this plugin to expose the ACF fields:
GitHub - airesvsg/acf-to-rest-api: Exposes Advanced Custom Fields Endpoints in the WordPress REST API
And now my fields show up like this:
But maybe on the “Name” “Value” I’m doing something wrong?
Also why are there 2 JSON values? One with ACF: and one without. Also, “cost-1” and “cost1” are different.
The second field probably appeared when you made the first request, when you make POST requests in WordPress and field does not exist, WordPress creates that as metadata as custom field in the post meta:
Would be the equivalent of this:
If you add this plugin
JSM's Show Post Metadata – WordPress plugin | WordPress.org
You should be able to see that field without ACF in the Post Meta.
@Jorge_M , Yes, you’re right. Do you have any idea anyway how can I update those values under “acf”, now that they are under the correct form?
You need to make a second call to update the ACF fields, After you 1st POST request you need to call another POST request, this time using ID to update, but try to use RAW instead of fields and build the JSON with example as I showed
“field 1”: “Abraham (Abe) Simpson”,
“field 2”: “data here”,
“field 3”: “data here”
@Jorge_M , as you can see attached, I have executed the workflow with the new settings, but nothing happens. Any idea why?
Interesting, can you try replacing “acf” for “fields” like this:
"Yourfield1" : "XXX",
"Yourfield2" : 111
Also please confirm you have this activated, sometimes we just forget:
@Jorge_M , I’ve tried and it doesn’t work. Also “Show in REST API” is “Yes”.
Ok that is strange, try exposing the REST API with
ACF to REST API – WordPress plugin | WordPress.org.
Maybe the endpoints are not properly registered.
@Jorge_M I did installed the plugin as I said in my 2nd reply, and they are exposed correctly but I don’t understand why they are not updated.
Ok, that is weird then, if you want to dm me the details, I can check with you, but without more details, it seems a dead end so far
Here you go, I tested it and it working well like this.
@Jorge_M Hi. I’ve tried and still doesn’t work. I’ve also tried with “acf” instead of “fields” but no luck for me.
Then is something outside ACF itself, only debugging your site I can see what is going wrong.
@Jorge_M. I would greatly appreciate if you can take a look as I think I’ve tried everything and it still doesn’t work. Can I send you a private message with the login details?
Sure, just send me the details via PM.
@Darius_Dumitru and @Jorge_M, I have the same issue.
I’m using n8n Desktop.app and Wordpress via localhost.
I did not get insert inside of acf field.
Did you get resolve this issue?
“ACF” is the response of the JSON body, basically ACF builds the extra fields on top of the WordPress API native fields.
In order to POST, you need to change “ACF” to “fields”.
Did you manage to get this running?