Support

Account

Home Forums General Issues Create a post with custom fields with php

Solved

Create a post with custom fields with php

    • rib56

    • July 13, 2013 at 7:00 am

    Hey guys,

    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?

    Thanks!

  • 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. 😀

    • rib56

    • July 14, 2013 at 6:57 am

    Many thanks! This did the trick 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.