WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)

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?

share|improve this question

marked as duplicate by kaiser, Chip Bennett, scribu, EAMann Feb 28 '12 at 20:28

This question was marked as an exact duplicate of an existing question.

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. – Chip Bennett Feb 1 '12 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? – sxalexander Feb 1 '12 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. – Chip Bennett Feb 1 '12 at 23:46
@kaiser the other post pretty much answers my question in far better detail. I'm fine with closing this. – sxalexander Feb 3 '12 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 '12 at 20:28

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.

share|improve this answer

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