Custom Post Type hierachy
-
I have a rather specific problem – and a possible solution – I just wanted to ensure that what I am suggesting sounds sane before I start implementing!
I have an existing site, built over the top of a custom CMS, that publicises a number of events and I’d to migrate this to WordPress using custom post types.
Firstly some background:
I currently have 3 custom post types: events, speakers and venues
An event has a name, date, times, and a variety of other attributes specific to that event
An event also has a number of speakers who will be speaking at that event. These speakers may be speaking at several events.
An event also has a single venue assigned to it.I am trying to achieve the following URL structure:
https://www.mywebsite.com/new-york-2012 <– The event overview
https://www.mywebsite.com/new-york-2012/speakers <– A list of the speakers at the event
https://www.mywebsite.com/new-york-2012/venue <– Information on the venue where the event is being held
https://www.mywebsite.com/new-york-2012/register <– A data collection pageCurrently, having the event custom post type gives me the following:
https://www.mywebsite.com/event/new-york-2012
and I believe that I can use URL rewriting to remove the ‘event’ bit. However, I am at a loss in how to have the other pages (which, across different events, will share the same set of templates) appear as children of this custom post type.
I guess an option would be to create templates that queried the URL string for the event name, then ran a WP Query to get the information to display. For example, for the venue page, it would query the URL string and from that be able to use both the event attributes and venue info on the page (a Venue is assigned to an event using the Advanced Custom Fields plugin).
But I just wanted to check if there is a cleaner or better way – perhaps using categories or hierarchies? Sorry for the long winded explanation, please let me know if anything is unclear and I can give some examples.
Thanks!
- The topic ‘Custom Post Type hierachy’ is closed to new replies.