1. Home
  2. Addons
  3. Custom Post Types

Custom Post Types


Introduction
Installation
Settings
Link CPTs
Design
Support
FAQ – Frequently Asked Questions

Introduction

Your directory can use Custom Post Types to create distinct listings with different fields. This is an important tool if you want your directory to be diverse, to include different types of listings. With the addon you can create and manage new custom post types. Get the Custom Post Types add-on for GeoDirectory and get started.

See more here: https://wpgeodirectory.com/downloads/custom-post-types/

Installation

Preparation

Check to be sure you have the following plugins installed before you get started.

Installation

  1. Download the Addon from your account.
  2. Install the Addon.

Settings

Basic Settings

Advanced Settings

Link CPTs

To Link one CPT to another, visit the Custom Post Type Settings Custom Fields tab.

CPT link fields are near the bottom of the page. Choose a link type and click to add to your CPT listing form.

A view of the complete custom fields tab, with the Link fields near the bottom left.

Link CPT Field Settings

Adjust field settings as desired. If you want to allow a link to more than one post, then make sure to set the value for Max to more than 1.

You can link ‘from’ hospitals to Doctors. Each such link would allow the hospital to link to one or more doctors.
You can link ‘from’ Doctors to hospitals. Each such link would allow a doctor listing to link to one or more hospitals.

Use the custom field ‘linked from’ in the Hospital Settings – Custom Fields – Custom Fields

Link from Hospital to the Doctor

Link from Doctor to Hospital

Design

gd_linked_posts

The Custom Post Types addon enables a new design element called gd_linked_posts. This element is available as a widget, block, or shortcode.

Use the element to display linked posts.

Example of the gd_linked_posts shortcode:

[gd_linked_posts title="Custom Title" id="-4" link_type="to" post_type="gd_hospital" sort_by="az" title_tag="h3" layout="list" post_limit="5"]

Shortcode builder options:

Sorting linked Events by Date

It is possible to sort gd_linked_posts shortcode (only) by event date, but first make sure the sorting options are set to sort by date. Visit:

Events (CPT) – Settings – Sorting (Tab) – Event Date. Choose event date and use as the primary sort

Then in your shortcode, substitute

sort_by="event_dates_asc"

Customize

For more information about using CSS and PHP customization snippets please see our doc about customizing.

Snippets from the forum

Hide CPT B fromPost Type Select on Directory Map on Archive for CPT A. See this topic.

Get Support

Get support on our forum, find out more here: https://wpgeodirectory.com/docs-v2/geodirectory/support/

FAQ – Frequently Asked Questions

Can the Title, Description and Address be set to autocomplete and pull the information from the linked post?

Not at this time because each post type can be linked to multiple other posts.

Can I hide a single CPT from the search bar selector?

Here is an example of how that can be done for a CPT called gd_schools in a snippet.

GD Linked Posts

Alter Layout of Linked Posts

When you add GD Linked Posts custom field to your Tabs UI there isn’t an option to adjust the layout.
To adjust the layout you will need to add a shortcode custom field in the tabsUI and use a shortcode in that shortcode field with the layout or other options you want.

In this example we want to show linked events as a list. Events are linked TO the Places, but we are adding the list of events ON the places detail tabs, so for our shortcode, we want to show listings linked “From” the Events post type. And of course we need to add that layout=”list” to make it the way we want.

Step by step:

  • Open the places settings and click the Tabs (tab)
  • Add a shortcode custom field
  • Use a shortcode builder to create the GD Linked Posts shortcode that you want ex.
    [gd_linked_posts link_type="from" post_type="gd_event" sort_by="az" title_tag="h3" layout="list" post_limit="1000"]
  • Add the shortcode to the shortcode field
  • Name your tab and choose and icon and save
  • Check the detail page to see the new layout in the new tab
  • Remvoe the old field from the tabs if you don’t want it anymore
  • Bob’s your uncle

Multiple Links to the Same Post Type

With the Custom Post Types Addon installed it is possible to create one (1) link from each Custom Post Type to any other post type (including itself).

Though a project may benefit from a second (or N additional) link field, perhaps for a different kind of relationship, this is would be a customization that would require custom code and falls outside of support.

Changes in V2 Custom Post Types

Auto-fill
– In V1 it was possible to auto-fill the basic business info when adding a link event to a place. This is no longer possible in V2 because the link field supports multiple linked posts.

Was this helpful to you? Yes 5 No 3