I’d like to create a post with some ACF with php code (because I need to inject some contents from another source).
I saw the tuto using-acf_form-to-create-a-new-post and acfsave_post but I can’t figure how to create the custom fields.
What’s the trick?
Are you creating the custom fields from scratch and adding them to a field group, ie. outside of the post itself? If so, set up a sample custom field group and choose PHP export – you’ll get a PHP file that you can include in your script that you can tweak to add new custom fields to the field group.
On the other hand, if you’re just adding content to a post during post creation, I think you can save the custom field content as meta data: http://codex.wordpress.org/Function_Reference/update_post_meta.
But don’t quote me on that! There’s probably an ACF method to add data to posts on creation. 😀
Many thanks! This did the trick 🙂