I'm creating a WordPress site that has 3 custom post types registered: course
, chapter
, and lesson
.
All of these post types are inter-connected and share a relationship using custom fields. For example, the chapter
has a custom field that stores the course
post object in which it belongs to. Same goes for the lesson
and the chapter
it belongs to.
My permalink settings are using the: %category%/%postname%/
structure, in which display the post's URL like so:
www.domainname.com/custom-post-type-name/post-name
What i'm trying to accomplish is to create a custom permalink structure that shows the relationship between these 3 post types in the URL. Example below:
When user is on course:
www.domainname.com/course
When user is on a chapter:
www.domainname.com/course/chapter
When a user is on a lesson: www.domainname.com/course/chapter/lesson
While looking in the WordPress Codex, I found the the Rewrite API and WP_Rewrite(), I'm a little lost and i do not know where to begin.
Any help on this would be greatly appreciated.