Back to contents

WordPress Relations Feature Settings Overview

 

This tutorial explains how to set relations between data using JetEngine for WordPress and scrutinizes its features.

JetEngine makes it possible to manage the parent/child and grandparent/grandchild relations between different types of data (WordPress Custom Fields in CPTs, CCTs, taxonomy items, and users). It can connect/sort/filter/search related items on the front end (with other JetPlugins) using JetFormBuilder, apply filters to relations and different macros to output the related objects’ data in listings, and develop CPT relations in REST-API.

Tutorial requirements:

The current version of JetEngine maintains both the refactored features of Relations for Post Types (which stays as a legacy one) and new features available for users, taxonomies, and CCTs. Also, you can add meta fields to the relations and directly create or connect child and parent items from the related items’ editing areas.

To find the Relations tab, navigate the JetEngine plugin menu in the WordPress admin dashboard.

jetengine menu

Here you can update the relation settings by hitting the “Clear the legaсy data” button. After that, all posts will be automatically transferred, but you must manually change macros used for relations.

legacy relations

General Settings

The Relations tab has the following settings: General Settings, Labels, and Meta Field. Let’s look at the General Settings in more detail.

add relation settings

Currently, there are 14 General Settings in this block. They are:

relations general settings

  • Name to set a unique name for the current relation that will later be shown in macros and dynamic tag settings. JetEngine does not limit the number of characters for this field and allows the use of spaces and punctuation marks.
  • Parent object to select the main object (post type, taxonomy, user, or CCT) for current relation. You can choose one from the drop-down menu. So, keep in mind that you have previously created the parent object.
parent object field relation menu

  • Child  object to select a child object for current relation (e.g., post type, taxonomy, users, or CPT). So, keep in mind that you have previously created the parent object. You can choose one from the drop-down menu.
  • child object field relation menu

  • Relation type to pick one of the available types: One to one, One to many, and Many to many.
  • relation type field relation menu

    Check the detailed information about relation types through our tutorial How to Choose and Set Post Relations (Legacy).

  • Parent relation to select a grandparent relation using the previously developed one (e.g., Continent > Country > City).
  • parent relation field relation menu

    The following settings are toggles to turn on/off the appropriate functions.

    • Register controls for parent object to add a user interface (UI) to manage related items on the parent object editing area (e.g., on the editing areas of the post, user, and term).
    • Allow to create new children from parent to create new child-related items from the parent object editing page.

    If you turn on this option, a page you edit will look as follows 一 you will be able to add child CPTs (i.e., Tour) to the parent CPT (i.e., Country).

    adding child cpt

  • Register controls for child object to add a user interface (UI) to manage related items on the child object editing area (e.g., on the editing areas of the post, user, term).
  • register controls for child object

  • Allow to create new parents from children to create new parents-related items from the child object editing page.
  • adding parent cpt

  • Allow to delete parents from children to delete parents’ items from the related items control for a child object page.
  • register controls for parent object

  • Register separate DB table. This option registers the relation to a different Dashboard table (otherwise, all related items are stored in the same table for relations).
  • register separate db table setting

  • Register get items/item REST API Endpoint to get content type items. If you turn on this toggle, you will see a text in the Endpoint URL field to copy to the Rest API to specify the children and the parent objects. Besides, you can fill the Access Capability field to define the roles, i.e., to set user access capability: the site admin has full access, and you can leave this field empty to allow public access. 
  • Read more about Roles and Capabilities – WordPress.org Forums.

    register get items/item rest api endpoint toggle

  • Register update REST API Endpoint to update the related items. If you turn on this toggle, you will see a text in the Endpoint URL field to copy to the Rest API to insert/update new data you need to send a POST request to a given URL. Besides, you can specify the roles, i.e., to set user access capability: the admin of the site has full access, and you can leave this field empty to allow public access. 
  • register update rest api endpoint

    If you select a CCT as a parent or child object, a block with the following settings appears below the General Settings:

    • Title field. Pick a CCT field from where the titles will be taken for the related items when you connect a new related item;
    • Create fields. Here, you can choose the CCT fields to fill when creating a new child CCT item on the parent editing page or a new parent CCT item on the child editing page.
    content type related settings

    To learn more about the related Custom Content Type items, check this tutorial.

    Labels

    In the Labels block, you can set how relation settings will look in the dashboard. The Labels for the parent or child objects will appear if you enable the Register controls for parent/child object toggle. Also, some labels are dependent on the Allow to create new parents/children from children/parent toggles.

    • Parent Object: label of relation box. It’s a custom label for the relation box on the parent object editing page;
    • Parent Object: label of connect button. It’s a custom label for the button for connecting related items on the parent object editing page;
    • Parent Object: label of select item control. It’s a custom label for the control for items selection on the parent object editing page;
    • Parent Object: label of create button. It’s a custom label for the button for creating related items on the parent object editing page;
    • Child Object: label of relation box. It’s a custom label for the relation box on the child object editing page;
    • Child Object: label of connect button. It’s a custom label for the button for connecting related items on the child object editing page;
    • Child Object: label of select item control. It’s a custom label for the control for items selection on the child object editing page;
    • Child Object: label of create button. It’s a custom label for the button for creating related items on the child object editing page.
    relation labels

    For example, we have created the relation, where users are the parent object and pages are the child object and added such Labels.

    relation labels example

    Let’s proceed to the child page. Here we can see the list of the parent items and create and connect them if needed.

    child object with the labels

    Once we hit the “Connect” button, the pop-up with the select item control will appear.

    select item control

    Such settings are analogous to those on the parent object page, where you can see, create and connect the child items.

    Meta Fields

    The meta field functionality is the same as in the post types, taxonomies, and meta boxes, but not all the field types are available because they are not compatible with the UI due to restrictions.

    meta fields in relations

    After creating meta fields and ending with other relation settings, click on the “Publish Relation” or “Update Relation” button. Then proceed to the child or parent editing page (for instance, we have navigated to the provider post type and hit the “Edit” button of one of the posts).

    Push the button of related item creation or connection. In the first pop-up, you will need to enter the name of the created item or select the title of the connected one. In the second pop-up, you can fill the meta field data.

    save meta data

    Also, to fill the meta field, you can press the “Edit Meta” button. Here you get the same pop-up, as on the previous screenshot, where you can edit or enter new meta data. After you finish, click on the “Save Meta Data” button and close the pop-up.

    edit meta button

    If you end, update, or publish the object (post, CCT item, term, etc.), which you edited.

    Press to edit a Single Page or Listing Item via the Elementor or Gutenberg editors and drag-n-drop the Dynamic Field widget or block to display the meta fields of related items. Select the “Relation Meta Data” Source and the name of the needed Meta Field. Lastly, select the “Related Items From…” Context.

    relation meta data in the dynamic field

    There are the same settings in the Dynamic Field block in the Gutenberg editor.

    dynamic field block with the relation meta data source

    We have placed the meta field on the Parent Single Page and in the Listing with the related children items.

    meta field of the related items

    To display only the related children service posts below the parent provider post we have used the Post Type Query with the Related Items macro in the Listing Grid.

    query for the related post tepes

    To apply the query to the Listing Grid proceed to the Custom Query section in the widget Content settings, enable the toggle and select the query for relations.

    custom query

    To learn more about the query and macros for relations, proceed to this tutorial.

    Admin Column

    To organize your posts more appropriately, you can display the related items in the Admin Column in the CPT.

    admin column for the related items

    Go to JetEngine > Post Types and click the “Edit” button near the needed CPT. “Add new” admin column, give it a title, and select the “Custom Callback” Type. Click the “Select from existing callbacks” line in the Callback field.

    set up the admin column

    In the appeared window, select the jet_engine_custom_cb_related_items callback.

    Choose the relation for this admin column in the next window and tick the “Apply” button.

    relation for the admin column

    Update” the CPT, proceed to the post type tab on the WordPress Dashboard and check the admin column with the related items.

    Admin Filter

    With the Admin Filters feature, you can filter the posts list by the related items.

    admin filter for the related items

    Go to JetEngine > Post Types and click the “Edit” button near the needed CPT. “Add new” admin filter, give it a name, and select the “Filter by related items” Type. In the new Relation field, select the needed relation.

    set up the admin filter for relation

    Update” the CPT, proceed to the post type tab on the WordPress Dashboard, and filter posts by the related items.

    That’s it. You know now all about the JetEngine relations feature settings and how they can help you create or connect the related items on the parent or child editing page.