Need help with complex custom post type setup

Ok, that is complicated 🙂
Have you considered using rewrite endpoints?

I would not try and cram everything into the url unless you have a specific need or a requirement for that.

domain/<series>/<episode-name> would be going directly to the episode CPT

domain/cartoon-series/<series> – would go the the series CPT

Then using rewrite endpoints to have features for these urls:

domain/cartoon-series/<series>/gallery

domain/cartoon-series/<series>/description

You would add something like this to allow these (/gallery and /description) endpoints:

function add_endpoints() {
    add_rewrite_endpoint('gallery', EP_PERMALINK);        
    add_rewrite_endpoint('description', EP_PERMALINK );        
}
add_action( 'init', 'add_endpoints', 0);

And have code to handle the endpoints in the default CPT template for cartoon-series.

Another way would be to do what you already considered, which is, setup cartoon-series as a taxonomy and then use the rewrite endpoints and parse them in the category.php file?

I hope this helps you in some way.

**Another Option

Don’t create a CPT for Cartoon Series. Leave it as a category that it can be used in both Episode CPT and Feature CPT:

Categories
Series
Series1
Series2
Series3

Episode CPT
Special Features CPT

domain/cartoon-series/<series> – displays the category page (would list episode CPTs and feature CPTs) as well as pull
domain/cartoon-series/<series>/episodes – category page listing just episode CPTs (where “episodes” is a rewrite endpoint)
domain/cartoon-series/<series>/features – category page listing feature CPTs (where “features” is a rewrite endpoint)

The above would be rendered based on logic in category.php
Then

Episode CPT would be mapped to /episode/
Feature CPT mapped to /feature/

The problem would be getting this to work:

domain/cartoon-series//episode/ – displays the Episode CPT
domain/cartoon-series//feature/ – displays the Feature CPT

And of course you would need to somehow pull the info on the series as well.

Leave a Comment