Help Center
How to Assign Custom Content Type Posts to Users

How to Assign Custom Content Type Posts to Users

Dive deep into this step-by-step guide to learn more about how to relate WordPress users with Custom Content Type.

Before you start, check the tutorial requirements:

Let’s find out how to assign Custom Content Type posts to users in a few steps.

Look at the first part of the final result we get at the end of this tutorial.

final result on single

The second part is presented below.

final result listing

Create a Relation

Firstly, we need to create a Relation between our Custom Content Type and users. For this, navigate to the WordPress Dashboard > JetEngine > Relations. Press the “Add New” button to create a new relation.

create relation

Set a Name, and choose the Parent object and Child object. In our case, “Users” will be a Parent object, and CCT “Jobs Resume” – a Child object. Pick the “One to Many” Relation Type. After that, don’t forget to click the “Add Relation” button.

relation

You can enable other options in the General Settings section if needed. In our case, we leave Register controls for parent object and Register controls for child object toggles active.

relation register controls

In the Content Type Related Settings tab, we also need to select the Title field that will be used as a title of related items for the current CCT item.

relation content type related settings

In the Meta Fields section, add a meta field to the relation by pressing the “New Field” button.

relation add new meta field

Let’s create a “Checkbox” Field type meta field. The source will be chosen as Glossary.

relation meta field

To set the glossary, activate the Get options from the glossary toggle and select the Glossary you added earlier. For instance, ours is “Resume Categories.”

glossary

Once the adjustments are made, press the “Add Relation” button.

relation last step

Build Query with Query Builder

To show only related items in our listings. To build a new query, open the WordPress Dashboard > JetEngine > Query Builder directory.

query builder

Here, we need to create a CCT Query Type. Enter the new name, set “Custom Content Type Query” as Query Type, and don’t forget to specify the CCT we need.

add new query

In the Query section, click “Add new.”

query for cct

Here, we need to specify the Field, Compare operator, Value, and Type.  

In Field, select “Item ID” and set Compare operator as “Equal (=).” In the Value, press the Dynamic Tags button and find the “Related Items” macro. Then adjust the proceeding info, select the needed item as From Relation option, “Child Object” as From Object, and “Current Object ID” as Initial Object ID From.

Don’t forget to press the “Apply” button and pick Type as “Char”.

related items macro

Push the “Add Query” button after implementing the changes.

Connect User with CCT

Navigate to WordPress Dashboard > Users to connect already created CCT items and click on the “Connect Jobs Resume” button (the name can differ depending on the child object name and relation labels).

connect user and cct

In the dropdown list, pick the needed option and click the “Connect Jobs Resume” button.

select option in dropdown

In the next-appeared window, select the meta field you want to attach to this relation. Don’t forget to press the “Save Meta Data” button after.

add relation metafield to user

Work on other fields if needed and click the “Update User” button at the end of the page.

Add metadata to all needed users by following the steps described above.

Display Data in the Listing

Now, we need to create a listing for our Custom Content Type. Let’s move to WordPress Dashboard > JetEngine > Listings and click on the “Add New” button.

create listing

In the appeared pop-up, select the “Custom Content Type” Source, fill in the Listing item name, and pick the needed Listing view. In this tutorial, we will check how to create a listing both in Elementor and Gutenberg.

Press the “Create Listing Item” button to open the editor.

listing popup

Create listing in Elementor

With the help of the Dynamic Field widget, let’s display all the needed information we have in our CCT. Сhoose the “Post/Term/User/Object Data” Source and Object Field to display meta fields added to our CCT.

listing for cct

Now let’s display the meta field we created with our Relation. For this, add a new Dynamic Field widget, pick the “Relation Meta Data” Source and find the “Resume Categories” option, the name of the relation Meta Field. Select the option with a child object, as our CCT is a child in our Relation.

listing relation metafield

Once you finish, press the “Publish/Update” button.

Add listing to Single User Page

In the beginning, we’ve already created the listing template in Elementor. Now let’s add it to the Single User page created with the Profile Builder module. Navigate to the template assigned here in WordPress Dashboard > JetEngine > Profile Builder > User Page.

single user template

In the template, place a Listing Grid widget on the page. Select the newly built Listing. In the Custom Query tab, select the already created query built with Query Builder.

single user page query

Create Listing in Gutenberg

We can also create a nested Listing. For this, we need to create a new Listing template with source Users, where we’ll have user info displayed with Dynamic widgets and a Listing Grid widget with the listing for our CCT, which we created above. 

Let’s get back to WordPress Dashboard > JetEngine > Listings and click the “Add New” button.

listing in gutenberg

Select “Users” as a Source, set the needed name of the listing template and choose “Blocks (Gutenberg)” in the Listing view and click on the “Create Listing” button.

listing for users popup

We will add a Dynamic Field block to display the user’s name as well as the Listing Grid block. In the Listing field, select the listing we built earlier.

nested listing

Head to the Custom Query section. Here, enable the Use Custom Query toggle and choose the just created Custom Query item.

custom query

Press the “Publish/Update” button to save the changes.

The newly created listing will be displayed on the Public User Page built with the help of Profile Builder. Find the page you’ve added in WordPress Dashboard > JetEngine > Profile Builder > Pages > Users Page.

public users page

In Blocks Editor, add the Listing Grid block and select the nested listing we created just now. After all the changes, click the “Publish/Update” button.

gutenberg listing on users page

Final Result

And here are our results on the front end on the Single User Page:

final result single user page

And this is how our Listing created in Gutenberg looks like on Public Users Page:

final result public page

This is it; now you know how you can assign Custom Content Type posts to WordPress users by using the JetEngine plugin.

Was this article helpful?
YesNo

Need help?

Ask Facebook community

Get answers from 22K Crocoblock Community experts from all over the world.

Start a live chat

Ask question to support agent and share its details via chat messages.