{"id":22440,"date":"2016-07-05T13:24:40","date_gmt":"2016-07-05T13:24:40","guid":{"rendered":"https:\/\/wpgeodirectory.com\/docs\/?p=22440"},"modified":"2016-07-06T10:22:15","modified_gmt":"2016-07-06T10:22:15","slug":"linking-custom-post-types","status":"publish","type":"post","link":"https:\/\/wpgeodirectory.com\/docs\/linking-custom-post-types\/","title":{"rendered":"Linking Custom Post Types"},"content":{"rendered":"<h4>On this page:<\/h4>\n<ul>\n<li><a href=\"#intro\">Introduction<\/a><\/li>\n<li><a href=\"#applications\">Applications<\/a><\/li>\n<li><a href=\"#install\">Installation<\/a><\/li>\n<li><a href=\"#usage\">Usage<\/a><\/li>\n<\/ul>\n<h3><a id=\"intro\"><\/a>Introduction<\/h3>\n<p>With the <a href=\"https:\/\/wpgeodirectory.com\/downloads\/custom-post-types\/\">Custom Post Types (CPT) addon<\/a>, you can link two CPTs together, in the same way <a href=\"https:\/\/wpgeodirectory.com\/docs\/linking-events-to-places\/\">events can be linked to other listings<\/a>.<br \/>\nBecause CPTs can have different custom fields, pricing etc, this feature greatly enhances what can be listed on your site.<\/p>\n<h3><a name=\"applications\"><\/a>Applications<\/h3>\n<p><i class=\"fa fa-lightbulb-o fa-2x\" style=\"color: green;\"><\/i> Here are a few examples to give you an idea how you could use this feature:<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>CPT<\/strong><\/td>\n<td><strong>Linked to CPT<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Fast food chain<\/td>\n<td>Our hamburgers<\/td>\n<\/tr>\n<tr>\n<td>Rock band<\/td>\n<td>All\u00a0regular venues where the band plays<\/td>\n<\/tr>\n<tr>\n<td>Car brands<\/td>\n<td>Our models<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>For the rest of the article we will use a car manufacturer CPT, and a car model CPT.<\/p>\n<h3><a name=\"install\"><\/a>Installation<\/h3>\n<ol>\n<li>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:<br \/>\n<table>\n<tbody>\n<tr>\n<td><strong>CPT<\/strong><\/td>\n<td><strong>Cars<\/strong><\/td>\n<td><strong>Models<\/strong><\/td>\n<td><strong>Comments<\/strong><\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/wpgeodirectory.com\/docs\/core-general\/#physical\">Has address<\/a><\/td>\n<td>Yes<\/td>\n<td>No<\/td>\n<td>We do not need addresses for the car models (optional)<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/wpgeodirectory.com\/docs\/category\/addons\/franchise-manager\/\">Franchise enabled<\/a><\/td>\n<td>Yes<\/td>\n<td>No<\/td>\n<td>We will allow dealerships to be added (optional)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>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 <em><strong>GD &gt; Custom Post Types &gt; Model CPT (example only) &gt; Advanced Mode &gt; Link business.<\/strong><\/em><\/li>\n<li>Tick <em><strong>Link Business<\/strong><\/em>, select the CPT you want to link it to, and <em><strong>Save<\/strong><\/em>.<br \/>\n<img loading=\"lazy\" class=\"greenborder\" src=\"https:\/\/wpgeodirectory.com\/docs\/wp-content\/uploads\/sites\/3\/2016\/07\/cpt1.png\" width=\"649\" height=\"325\" \/><\/li>\n<\/ol>\n<h3><a id=\"usage\"><\/a>Usage<\/h3>\n<ol>\n<li>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).<\/li>\n<li>The Add Listing form for the linked CPT will have\u00a0a search\u00a0option to find the listing in the linkable CPT:<br \/>\n<img loading=\"lazy\" class=\"greenborder\" src=\"https:\/\/wpgeodirectory.com\/docs\/wp-content\/uploads\/sites\/3\/2016\/07\/cpt2.png\" width=\"618\" height=\"130\" \/><\/li>\n<li>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).<br \/>\n<img loading=\"lazy\" class=\"greenborder\" src=\"https:\/\/wpgeodirectory.com\/docs\/wp-content\/uploads\/sites\/3\/2016\/07\/cpt3.png\" width=\"618\" height=\"151\" \/><\/li>\n<li><i class=\"fa fa-exclamation-triangle fa-2x\" style=\"color: orange;\"><\/i>You cannot connect a\u00a0listing\u00a0to a linkable CPT listing of another user (unless you are an administrator).<\/li>\n<li>When the system finds the listing, select it and click <strong>Fill in business details<\/strong>.<\/li>\n<li>This will pre-fill some fields of the new listing\u00a0with the same data as the linkable\u00a0listing.<\/li>\n<li>Change title, description etc as required.<\/li>\n<li>And this is how it will look, in the sidebar you will get a link from all linked listings to the linkable listing:<br \/>\n<img loading=\"lazy\" class=\"greenborder\" src=\"https:\/\/wpgeodirectory.com\/docs\/wp-content\/uploads\/sites\/3\/2016\/07\/cpt4.png\" alt=\"\" width=\"316\" height=\"83\" \/><br \/>\nand on the detail page of that linkable listing, you will get a tab with all linked listings&#8221;<br \/>\n<img loading=\"lazy\" class=\"greenborder\" src=\"https:\/\/wpgeodirectory.com\/docs\/wp-content\/uploads\/sites\/3\/2016\/07\/cpt5.png\" alt=\"\" width=\"650\" height=\"258\" \/><\/li>\n<li><i class=\"fa fa-lightbulb-o fa-2x\" style=\"color: green;\"><\/i> To change the layout in the tab with linked listings, go to <em><strong>GD &gt; Design &gt; Detail tab &gt; Related Post Settings &gt; Layout<\/strong><\/em>, and select the list view or the grid view of your choice there:<br \/>\n<img loading=\"lazy\" class=\"greenborder\" src=\"https:\/\/wpgeodirectory.com\/docs\/wp-content\/uploads\/sites\/3\/2016\/07\/cpt6.png\" alt=\"\" width=\"521\" height=\"124\" \/><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>On this page: Introduction Applications Installation Usage 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 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/wpgeodirectory.com\/docs\/linking-custom-post-types\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Linking Custom Post Types&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1676,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[64],"tags":[],"amp_validity":null,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/posts\/22440"}],"collection":[{"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/users\/1676"}],"replies":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/comments?post=22440"}],"version-history":[{"count":0,"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/posts\/22440\/revisions"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/media?parent=22440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/categories?post=22440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/tags?post=22440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}