at the moment i stuck a little bit at my new wordpress project.

The basics are: The user can create nutrition plans and there he can add some recipes, so i need to build a relationship from user > nutrition plans > recipes and at the moment i dont have any ideas how to solve this problem with wordpress and acf.

At the moment the user can select his recipes and create a new "private" nutrition plan. But now i want to save the id's of his selected recipes to a acf repeater field.

So far thats all i have:

$new_post = array(
        'post_title'    =>   $title,
        'post_content'  =>   $description,
        'post_category' =>   array($_POST['cat']),  // Usable for custom taxonomies too
        'tags_input'    =>   array($tags),
        'post_status'   =>   'private',           // Choose: publish, preview, future, draft, etc.
        'post_type'     =>   'ernaehrungsplan'    //'post',page' or use a custom post type if you want to

    $pid = wp_insert_post($new_post);

At this point i stuck a little bit because the update_field() method is only for existing posts? right? Maybe someone can help me :)

Thanks a lot!


After you have inserted the post your $pid variable should contain the ID of the post, which you can use calling update_field()

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.