Albion Selimaj
Oct 1 · 7 min read

Related Listings

The “Related Listings” feature has been redesigned to offer incredible versatility through different relation types, two-way relations, and more configurable settings which we’ll explain below.

Let’s start by showing how the new field settings look, then go through everything step-by-step.

Related Listing Field Settings

The “Related To” setting

This setting allows you to set what type of listings you’re allowing on this field. All listing types registered on your site will be listed as checkboxes. This also means that the relations are no longer limited to only one other listing type — you can choose one or more types from the list, if your use-case requires that.

Limit listing selections by author

This settings lets you set whether the user can select only listings that belong to them, or all listings that belong to any author.

Limit listing selections by status

You can also allow users to pre-select listings that haven’t been approved yet. They will then be shown in the single listing page once they’re published.

Four possible relation types

There are four possible relation types supported, which cover a wide range of possible use cases: Has One, Has Many, Belongs To One, and Belongs To Many.

We’ll explain how each of these relations work and how you can incorporate them with your existing listing types.

Has One and Belongs to One

This relation can be used if the active listing is related to one other listing. For
example, an Event listing can have only one Place listing it’s related to, and a Job listing can only have one Company listing that it belongs to.

The only difference between Has One and Belongs To One relations is that Has One treats the active listing as the parent and the related listing as the child in the relation; while Belongs To One treats the active listing as the child and it’s related listing as the parent in the relation.

Has Many and Belongs To Many

This relation can be used if the active listing is related to multiple other listings. For example, a Place listing can have multiple Event listings it’s related to, and a Company listing can have multiple Job listings it’s related to.

Has Many treats the active listing as the parent and all it’s related listings as child listings in the relation; while Belongs To Many treats the active listing as the child and all related listings are treated as parent listings in the relation.

In most cases, it doesn’t matter which listing is treated as parent and which as child. This is only important if you’re setting up two-way relations, which will be explained next.

Related Listing Field With A “Has Many” Relation Type

How do Two-Way relations work

Let’s take an example: A Company listing can have multiple Job listings, and a Job listing will have one Company listing that it belongs to. Through Two-Way relations, we can sync the related listing field value across both the Company and it’s jobs, which makes managing relations much easier as you’ll only have to edit them on one listing and it will automatically be updated everywhere.

In that case:

  • Editing a Company and assigning some Job listings to it will also update each of those jobs and assign the Company as their related listing
  • Editing a Job listing and assigning a company to it will also update the Company listing and apply this Job as one of it’s related listings

How to set up two-way relations

Following up on the example above:
1. First, we need to define which side of the relation will be the parent and which the child. In this case, we can treat the Company as the parent, and Jobs as the children.
2. In the Company listing type, we can use the Related Listing field, and configure it as follows:
1. Set the Related To setting to Jobs
2. Set the Relation Type to Has Many (since a company can have multiple job listings)
3. In the Job listing type we should configure the Related Listing field as follows:
1. Set the Related To setting to Company
2. Set the Relation Type setting to Belongs To One (since a job listing can only belong to one company listing)
4. If you’re using a custom “Related Listing” field instead of the default preset, then you must also make sure the field key is the same in both listing types.
5. That’s it — the Related Listing field is now synced among the Company and its Job listings.

To sum it up, for two way relations to work, one side of the relation must have the relation type set to either “Has One” or “Has Many”, and the other side must be set to either “Belongs To One” or “Belongs To Many”. The Related Listing field key must also match on both listing types.

Is it possible to have multiple related listing fields

Yes — apart from the preset Related Listing field, you can also create custom related listing fields in the Fields tab > Create a Custom Field > Relational, and choose Related Listings from the list.

Adding A Custom “Related Listing” Field

How to display related listings

You can display related listings in the frontend in multiple ways:
1. As a tab in single listing page — you can create a new “Related Listings” tab, and choose the Related Listing field to fetch listings from.
2. As a content block in single listing page — you can add the “Related Listing” content block to the profile tab or within a custom tab.
3. In the preview card, under “Footer sections” you can add a “Related Listing” section.

Related Listings Tab In The Single Listing Page

How to use the Related Listing filter in Explore page

It is also possible to use Related Listing fields as Explore page filters. This can be done through the new Related Listing filter in Search Forms > Advanced Form and Search Forms > Basic Form within the listing type editor.


Direct Messages: Listing Specific Conversations

We’ve changed a little bit how direct messages to a listing work. Previously, the “Direct Message” quick action simple forwarded you to the listing author. This method works well enough for most cases, but has it’s shortcomings, mainly: if a user owns multiple listings, then all those listings will share the same conversation.

To solve this, we’ve implemented conversations at the listing level, so each listing actually gets it’s unique conversation screen, even if they have the same author.

The listing author information is also no longer shown — they’re replaced by the listing name and logo. This works better for the user who messages the listing, as they will see the name of the listing they messaged, not it’s author which could be confusing.

It also works better for the listing owner, as all messages they receive will now show the source where they came from — either as a direct message to the user, or a message to one of their listings, as shown in the picture below.

Direct Message To A Listing You Own

User Dashboard Improvements

The User Dashboard > My Listings page now features a dropdown for filtering user listings based on their status. Apart from the usual Published, Pending Approval, and Expired listings, this dropdown also supports Pending Payment and Preview listings.

For Pending Payment and Preview listings, users now also have the option to continue the listing submission through the Resume Submission action (see picture below).

Listing Type Editor Improvements

The listing type editor has been refreshed with a cleaner and more responsive interface. It handles listing types with large config files better, and the Export Config feature has been optimized to produce lighter files.


Before Updating

As always, make sure you backup your site before installing this update.

There have been some changes to the file structure within the theme folder, so if you’re using a child theme to modify any of the core theme files, make sure it’s compatible with the latest version before installing the update. The main changes are:

  • All content block templates have been moved from the “sections/” directory to “templates/single-listing/content-blocks/”.
  • All Explore page filter templates have been moved from “partials/facets/” to “templates/explore/filters/” directory.

Full Changelog

27collective

We create beautiful & functional WordPress themes

Albion Selimaj

Written by

Web Developer at 27collective

27collective

We create beautiful & functional WordPress themes

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade