0

I have a hierarchical custom post type (missions) setup. I want to create a few child pages for it (discuss, petition, educate), but I want each of those child pages to display a different template.

There does not appear to be a way to use a selected template, like on a normal page, so I thought maybe I could just have the child custom post type pages display content based on their slug.

So the permalinks would appear as:

/mission/mission-01/
 - /mission/mission-01/discuss/
 - /mission/mission-01/petition/
 - /mission/mission-01/educate/

/mission/mission-02/
 - /mission/mission-02/discuss/
 - /mission/mission-02/petition/
 - /mission/mission-02/educate/

Since they are children, and the Discuss pages could all use the same slug, maybe a function that gives all pages with slug /discuss/ the page-discuss-template.php from my theme directory.

Thanks for any help!

5
  • With Custom Post Types you indeed cannot choose a template like you can for "normal" pages, but you can make a template called missions.php which will be called before page.php if it exists. I don't know however how this will work with children of the custom post type, but you could try it out to see what happens?
    – user2015
    Commented Apr 15, 2011 at 2:21
  • 2
    the only problem i see is that you can't have two pages with the same slug, but there is a solution take a look at wordpress.stackexchange.com/questions/8608/… and to that you just need to add a rewrite rule to make the links nice.
    – Bainternet
    Commented Apr 15, 2011 at 2:38
  • 2
    Also, check @Mike Schinkel's answer to this question - wordpress.stackexchange.com/questions/858/… - which seems to be after a similar solution as you're looking for. Commented Apr 15, 2011 at 2:45
  • Thanks goldenapples. I believe Mike Schinkel's solution just might do the trick! Commented Apr 15, 2011 at 18:08
  • I actually ended up going with what you provided, Bainternet. Thanks to both of you guys. Commented Apr 15, 2011 at 20:41

1 Answer 1

0

There are two approaches to my question, that are both useful. They were provided by @goldenapples and @Bainternet.

Custom Post Type Data in Sidebar widgets?

How to quickly switch custom post type singular template?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.