3

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:

  • 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!

1 Answer 1

3

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-one, season-two etc. can be children of sample-series, like: site.com/series/sample-series/season-one, site.com/series/sample-series/season-two.

Similarly, episodes can be children of those seasons, like: site.com/series/sample-series/season-one/episode-one, site.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.

2
  • Thank you for your response. This seems to be a good approach, but one issue with it is that the archive page for the series (site.com/series) would also include the seasons and episodes, which is a problem here. I also want separate archive pages for seasons, episodes, and seasons. If this issue can be solved by applying a filter that would be awesome!
    – Mr Mousio
    Feb 1, 2023 at 22:39
  • You can customize the template files to achieve that.
    – Scott
    Feb 2, 2023 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.