Sauter la navigation

How to set up Post Relationships in WordPress

Toolset allows you to create post relationships in WordPress. Once the post types are related you can easily connect specific items directly from the post editor.

Durée

Creating relationships

Go to Toolset → Relationships, click the Add New button and follow the wizard.

Wizard for creating a post relationship

You can connect any post type (WordPress posts, pages, and custom post types) to other post types. First, choose the kind of relationship and then the type of post to be used on both sides of the relationship.

Different kinds of relationships for different cases

Toolset offers you to create one-to-one relationships, one-to-many and many-to-many relationships. Let’s quickly look at some examples of where you would use each.

One-to-one relationships

These are less common relationships, which you may use when you want to add more information to posts, without causing duplication.

For example, if you’re offering « downloads », you can connect the downloadable items with « download-counts ». This allows you to display the complete information about how many times each file was downloaded.

One-to-many relationships

Houses and rooms are a good example for « one-to-many » relationships. A house has many rooms, but each room belongs to only one house.

Many-to-many relationships

Events / speakers are an example of a many-to-many relationship. Each event will have many speakers and each speaker can appear in different events.

Giving meaningful names to relationships

Toolset will set a default name for the new relationships that you have established. Your site will be easier to manage if you consider what each relationship implies and create a meaningful name for each. For example, if you’re creating a site for « events » and « speakers », when you’re making the many-to-many relationship between the two types, a good name for this relationship is « lectures ».

Once you have set up relationships between posts, you can start connecting posts based on these relationships.

You can connect posts that you have already saved. This means that when you first create a new draft of a post, you must save or publish it before you can connect it with other posts.

You will see each of the available relationships (relationships that involve the post type you are editing) as a metabox on the post editing page.

Box with a list of connected posts

You can connect existing posts or create new posts.

To disconnect posts, hover over them in the connections table and additional options will appear.

The Disconnect operation will only disconnect posts. The Trash operation will both disconnect and delete the selected post.