Setting the Auto Parent-Child Relation to Posts Via a Front End Form (Legacy)
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.
Before you start, check the tutorial requirements:
- Elementor (Free version) or Block editor (Gutenberg)
- JetEngine plugin installed and activated
with the Relations (Legacy) configured and the Forms (Legacy) module enabled.
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:
Create a Test Form
Go to JetEngine > Forms > Add New and create a form that allows adding a new post from the frontend:
In the Post-submit actions, configure the notification type like so:
The relation meta key can be taken from here:
Display the Form on the Front-end
Open the Tour CPT and find the necessary post in the WordPress dashboard.
If it doesn’t exist, you need to create it either in the Elementor theme builder or in the Crocoblock theme builder:
Display the newly-created test form:
Fill in the Form
On the front-end, try filling out the added form and press the “Add new post” button:
Go to the backend and check out the result. You’re done!