Troubleshooting //
Setting the Auto Parent-Child Relation to Posts Via a Front End Form

Setting the Auto Parent-Child Relation to Posts Via a Front End Form

Question

How to set the parent (relation) to the child post from the frontend form?

Answer

One way to do that is to create a form for Child posts and display it on a Single template for Parent posts. It will have a required One to Many relation if you insert the relation meta key in the right field of the Form. To get started, please stick to the routine below.

Create a post types relation

Make sure that you do have the necessary post types to be interrelated. If not, create them. We’ll be referring to these two: Country & Tour. To create a relation, go to JetEngine > Relations and set the One to Many relation as shown below:

one to many relation’s settings

Create a test form

Go to JetEngine > Forms > Add New and create a form that allows adding a new post from the frontend:

form settings on the backend

In the Post-submit actions, configure the notification type like so:

insert/update post notification settings

The relation meta key can be taken from here:

posts relation meta key

Display the form on the frontend

Open the Tour CPT and find the necessary single page template. 

tour single page template

If it doesn’t exist, you need to create it either in the Elementor theme builder or in the Crocoblock theme builder:

single page edit with elementor

Display the newly-created test form:

new post form in elementor

Fill in the form

On the frontend, try filling out the added form and press the “Add new post” button:

frontend form submission

Go to the backend and check out the result. You’re done!

test tour post in the admin panel
Was this article helpful?
YesNo
Still need help?
Submit a request