Support

Account

Home Forums Front-end Issues Create Post if it doesn't exist in relationship field Reply To: Create Post if it doesn't exist in relationship field

  • Hi @maxaud

    If you want to do it via Ajax, you need to check how relationship field works, and it’s not an easy task to do as relationship field has a complex system.

    What I suggest you is to use a repeater to add a dummy post form to create the new post type 2. When the users save the post type 1, you need to use the acf/save_post hook to loop through the posted data and create them. After that, you can update the relationship field on the post type 1 with the newly created post type 2.

    You can also clear the posted data after that so the repeater form won’t looks ugly.

    I hope this makes sense 🙂