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!
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 ofseries
post type:site.com/series/sample-series/
.Then seasons named
season-one
,season-two
etc. can be children ofsample-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.