Skip Navigation

[Resolved] Link 2 CPTs

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

Problem:

You want to link "Documents" (CPT) to "Events" (CPT) so that certain documents can be associated with specific events and displayed dynamically on an event's page.

Solution:

One-to-Many Relationship:

- Use this if each Document is linked to only one Event.
- Example: A single Document can only be associated with one Event.

Many-to-Many Relationship:

- Use this if a Document can be linked to multiple Events and an Event can have multiple Documents.
- Example: Shared resources like policies or templates across multiple events.

Relevant Documentation:

https://toolset.com/course-chapter/using-post-relationships-on-directory-sites/

https://toolset.com/related-lesson/post-relationships/

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.

This topic contains 1 reply, has 1 voice.

Last updated by Christopher Amirian 3 weeks, 3 days ago.

Assisted by: Christopher Amirian.

Author
Posts
#2787873

I am currently building a new website and they have 2 main types of info. On the one hand Documents (title, description, author and a link to a pdf) and on the other hand Events (most likely via The Events Calendar). Both are displayed on different pages, so you can consult both the Documents and the Events.

Some documents must be linked to certain events and in order to avoid uploading the same Documents to (different) Events, I am wondering if in the Events CPT, can we select Documents from a dropdown to link them to that Event and then create a loop that extracts a Custom Field of each Document and display that in a View?

So an Event will have its title, description, date, ... and then an

    with the link to the pdf from the linked Documents.
#2788403

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Welcome to Toolset support. It seems that you need a relationship between the two post types in question.

But you need to decide if the relationship will be one-to-many or many-to-many.

You can learn more about relationships here:

https://toolset.com/course-chapter/using-post-relationships-on-directory-sites/

For a more detailed study you can check the lessons below:

https://toolset.com/related-lesson/post-relationships/

Thanks.