Skip Navigation

[Resolved] Linking content from one CPT to another in a post template

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to add a new type of content to my site and link it to an existing post type somehow. Should I use a new custom post type and post relationship, or should I use a repeatable field group (RFG)?

Solution: Either could work. Typically RFGs do not have single post pages or archives on the front-end of the site. Custom post types typically do have those, so that's one thing to consider when making your choice.

0% of people find this useful.

This support ticket is created 5 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by garyC 5 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#1320089

I have taken over the editing of a site that has been developed with Toolset and I need to expand the functionality of the current content. This is the current demo site link: hidden link

A custom post type was previously setup for 'businesses', with custom contact fields, that are displayed as a kind of categorised directory across the site. My client now wants to add a 'products' section to the site, which will display a product image, company details and an external link to the product on the businesses own website. This product section will likely need to be categorised, much like the business section. So customers can dial down to a specific type of product, such as 'Coffee' for example.

As the products are all going to be linked to a business that already exists on the site, what is the best way of linking this content rather than filling out all the business details again?

Can I create a new CPT for 'products' and then somehow have a dropdown on the post edit admin page that allows me to assign an existing business CPT to them, so I can load in the relevant business contact details into the 'product' single post template on the frontend? I've read that you can have post relationships, but cannot work out how I can manually assign one to the other.

Alternatively, I was thinking of adding product fields to the existing 'business' posts, but there may be multiple products for each business, so can you create a repeating group of custom fields, like you can with a single field? So when you wanted to add a new product, one click creates a new set of fields for product image / title / weblink?

Thanks in advance.

#1321301

As the products are all going to be linked to a business that already exists on the site, what is the best way of linking this content rather than filling out all the business details again?
Hi, you could use a Repeatable Field Group inside the Business post type to represent each Product. Or, you could use a custom post type Product in a relationship with the custom post type Business. The main difference here is that Repeatable Field Groups (RFGs) do not generally have their own single post page on the front-end of the site. So if you want to be able to have a single post page for each Product, RFG is not the best solution.

Can I create a new CPT for 'products' and then somehow have a dropdown on the post edit admin page that allows me to assign an existing business CPT to them, so I can load in the relevant business contact details into the 'product' single post template on the frontend?
Basically yes, this is how post relationships work. First, you set up the relationship in Toolset > Relationships. Then you can see in the single post editor an interface for creating a new related post, or linking to an existing post. See post-relationship-manager.png. In this case I am connecting Books and Chapters, and trying to find an existing Chapter to connect to the current Book.

Alternatively, I was thinking of adding product fields to the existing 'business' posts, but there may be multiple products for each business, so can you create a repeating group of custom fields, like you can with a single field?
This is how RFGs work, in general. But please see the information above to understand when it is better to use RFGs and when it is better to use a custom post type and a post relationship.

#1325247

Thanks Christian, the one to many post relationship works a treat. I created new posts for the products and enabled them to be linked to the business posts via this relationship. Many thanks.