Linking Custom Post Types

On this page:

Introduction

With the Custom Post Types (CPT) addon, you can link two CPTs together, in the same way events can be linked to other listings.
Because CPTs can have different custom fields, pricing etc, this feature greatly enhances what can be listed on your site.

Applications

Here are a few examples to give you an idea how you could use this feature:

CPT Linked to CPT
Fast food chain Our hamburgers
Rock band All regular venues where the band plays
Car brands Our models

For the rest of the article we will use a car manufacturer CPT, and a car model CPT.

Installation

  1. Create your CPTs and adjust all settings as required, below are the settings we use for the example. Note that this is only an example, adjust the settings for your situation:
    CPT Cars Models Comments
    Has address Yes No We do not need addresses for the car models (optional)
    Franchise enabled Yes No We will allow dealerships to be added (optional)
  2. Go to the settings for the CPT you want to be able to link to another CPT. In our example we want the different car models to be linked to the car CPT, so we go to GD > Custom Post Types > Model CPT (example only) > Advanced Mode > Link business.
  3. Tick Link Business, select the CPT you want to link it to, and Save.

Usage

  1. When a user now adds a listing in the linked CPT (Models in our example), they can link it to a listing in the linkable CPT (Cars in our example).
  2. The Add Listing form for the linked CPT will have a search option to find the listing in the linkable CPT:
  3. Start typing at least the first three letters of the listing you want to connect (this is not a search function, but a auto-population function).
  4. You cannot connect a listing to a linkable CPT listing of another user (unless you are an administrator).
  5. When the system finds the listing, select it and click Fill in business details.
  6. This will pre-fill some fields of the new listing with the same data as the linkable listing.
  7. Change title, description etc as required.
  8. And this is how it will look, in the sidebar you will get a link from all linked listings to the linkable listing:

    and on the detail page of that linkable listing, you will get a tab with all linked listings”
  9. To change the layout in the tab with linked listings, go to GD > Design > Detail tab > Related Post Settings > Layout, and select the list view or the grid view of your choice there: