What is the best way to relate different wordpress custom post types?

Let’s say I have 3 CPTs: series, seasons, and episodes. Now if I post in these custom post types the URL would be:

  • Series CPT > post name: sample serie > URL: site.com/series/sample-serie
  • Seasons CPT > post name: sample season > URL: site.com/seasons/sample-season
  • Episodes CPT > post name: sample episode > URL: site.com/episodes/sample-episode

Now what I want to do is combine these URLs together:

Read More
  • site.com/series/sample-serie/sample-season/sample-episode : To show the page for the sample episode (previously: site.com/episodes/sample-episode)
  • site.com/series/sample-serie/sample-season/ : To show the page for the sample season (previously: site.com/seasons/sample-season)

How can I implement this? Was creating 3 custom post types a good idea for doing this? Or is there any other methods to do this? (Preferably without any plugins)

Appreciate any further assistance!

Related posts

Leave a Reply

1 comment

  1. I think a better approach for this would be to create a single nested (hierarchical) custom post type.

    For example, it can be series.

    Then a single series named sample-series as a top level post of series post type: site.com/series/sample-series/.

    Then seasons named season-oneseason-two etc. can be children of sample-series, like: site.com/series/sample-series/season-onesite.com/series/sample-series/season-two.

    Similarly, episodes can be children of those seasons, like: site.com/series/sample-series/season-one/episode-onesite.com/series/sample-series/season-one/episode-two etc.

    Same thing can be done by default by WordPress page, since pages are by default hierarchical.