- Building a Relationship
- Parent Post Type Editor
- Child Post Type Editor
JetEngine allows setting different types of relations. For now, as part of the Refactored Relations feature, you can build relations between Custom Post Types, Custom Content Types, users, and taxonomies.
In this article, we revise the Custom Post Types relations. So, initially, check that you have created Custom Post Types that will be used as the parent and child of relation. Mind adding some posts to these relations.
Building a Relationship
Head to the WordPress Dashboard > JetEngine > Relations directory and push the “Add New” button to build a new relationship.
If you have already created some relations, you can also click on the “Edit” button next to the existing item to open the relations editor or hit the “Delete” button to remove the relation.
Set a Name for the relation and select the created post types as Parent object and Child object in the corresponding drop-down menus.
Proceed to the Relation type selector and pick the suitable option.
Once the type is defined, you can set the Parent relation if desired.
The following toggles allow registering more controls for the related items.
- Related controls for parent object — enable to add controls of the related children to the parent object;
- Allow to create new children from parent — toggle to allow creating new children from the parent object page;
- Register controls for child object — enable to add controls of the related parent to the child object;
- Allow to create new parents from children — toggle to allow creating new parents from the child object page;
- Register separate DB table — switch to create a new database only for the current relation. Otherwise, the data will be stored in the global relations database.
If desired, set the custom labels for the controls or leave them empty to see the default labels.
This tab allows setting meta fields for the relationship as a unit. Push the “New Field” button to add a new meta field.
Adjust the needed amount of the meta fields.
- Label — set a label that will be displayed next to the meta field;
- Name/ID — define a value stored in the database. Mind that this field should include only lowercase Latin letters with no spaces. Use “-” and “_” symbols to separate words;
- Field type — select the meta field type that will be displayed when the field in the post is being edited;
- Description — type in a meta field description if you want to show additional information about the field next to it;
- Is required — switch on to make the field obligatory for completing.
After making all the changes, push the “Add Relation” button.
Parent Post Type Editor
The editor will appear in the custom post type posts, both in the parent and child post types.
Let’s check the parent post type. Return to the WordPress Dashboard and head to the custom post type you have set as a Parent object.
Click on the “Edit” button next to any post to which you want to add related children.
As we have opened the parent object post type, head to the Children … tab. Here you can add, edit and delete all the needed posts as related child items. You can read more about the controls in this article.
Once the connections are made, press the “Update” button.
Repeat the previous steps for all the posts you want to relate with child posts.
Child Post Type Editor
If you want to work with the child object, return to the WordPress Dashboard and proceed to the post type you have set as a Child object.
Click on the “Edit” button next to any item to which you want to add related parent posts.
Go to the Parent … tab. Here you can set and delete relations with the parent object posts.
Don’t forget to update the post to save the result. This way, you can relate any children posts you need with parent post type items.
This is it; the WordPress CPT relation is set. Now you know how to relate items with one another using the JetEngine plugin.