Hierarchical Custom Post Types

I would like to have the following taxonomy structure:

site.com/courses/course-name/pathway/pathway-name

The domain is such that any particular course can be completed by taking a number of different pathways - different module structures.

The following URLS would work as such:

site.com/courses

shows a list of courses

site.com/courses/course-name

will follow a template e.g. single-course.php, showing title, content and a list of the pathways associated to this course.

site.com/courses/course-name/pathways/

will follow a template e.g. archive-pathway.php, showing course-name and a list of pathways (not be used so much but will still need to work)

site.com/courses/course-name/pathways/pathway-name

will follow a template, e.g. single-pathway.php, showing the course-name title, the pathway-name title and content for this pathway.

The files here may be incorrect whereby I should be using taxonomy-{}.php or otherwise as appropriate, instead of single-{}.php.

My question: is it possible to set up the above hierarchy within WordPress? If so, please provide some code to register_taxonomy or register_post_type as appropriate to help me get started.

I cannot find how to do this elsewhere but am pretty sure this is how courses in the TutsPlus network use WordPress.

Topic hierarchical custom-post-types Wordpress

Category Web


enter image description hereI'm not entirely sure if this will really help with exactly what you're looking for, but here is the WP template hierarchy. Personally solves a lot of my own questions & is a great reference to look back on


I ended up using Subordinate Post Type Helpers plugin to create relationships between two distinct custom post types: courses and pathways

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.