0

Possible Duplicate:
single-{$post_type}-{slug}.php for custom post types

I have registered a Custom Post Type named conference with the attribute:

'hierarchical' => true

In the backend admin, I created this nested post hierarchy for my conference posts:

Conference: Finding Vision (slug: 2011-finding-vision)
  -  Schedule (slug: 2011-finding-vision/schedule)
  -  Speakers (slug: 2011-finding-vision/speakers)
Conference: Returning to Basics (slug: 2012-returning-to-basics)
  -  Schedule (slug: 2012-returning-to-basics/schedule)
  -  Speakers (slug: 2012-returning-to-basics/speakers)
etc...

I know I can use single-conference.php as a default template for any of my conference post types. This works well for the parent conference posts.

My Question: Is there a default template that I can use to target posts that are child posts of a conference post?

Is there a way to have WordPress load single-conference-speakers.php or conference-speakers.php by default when rendering the url 2012-returning-to-basics/speakers?

With pages, this works. If I have a page with a slug of about, then I know I can make a template with page-about.php to have the WordPress Template Hierarchy use that template as a default template.

Does the equivalent exist for custom post types?

5
  • 1
    I would recommend re-thinking your schema. "Conference", "Schedule", and "Speaker", while related, are not the same type of content. You might be better-served by using a combination of Custom Post Types and Custom Taxonomies. Feb 1, 2012 at 21:31
  • That makes sense and does get at an underlying issue in my design. However, I'm still curious about whether there is an answer to my question. For instance, if instead of "conferences" this was "groups" how would I have sub-group templates? Feb 1, 2012 at 23:17
  • As far as I know, you can't. You'd have to do as @m0r7if3r suggests, and do some conditional querying within single-$posttype.php. Feb 1, 2012 at 23:46
  • @kaiser the other post pretty much answers my question in far better detail. I'm fine with closing this. Feb 3, 2012 at 23:51
  • In the future, please don't delete a dupe post like this (others had already linked to it). Moderators can merge duplicate posts so that useful answers aren't lost.
    – EAMann
    Feb 28, 2012 at 20:28

1 Answer 1

0

I'm not sure if it does exist, but it should. Try it and see. If it does not, you can use if statements within the single-$posttype.php in conjunction with is_page() (and the other conditional tags(http://codex.wordpress.org/Conditional_Tags), if needed) to duplicate that functionality.

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