Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#12385 closed defect (bug) (worksforme)

it's unclear which template file is used by custom post types

Reported by: danielpataki's profile danielpataki Owned by:
Milestone: Priority: normal
Severity: major Version: 3.0
Component: Template Keywords:
Focuses: Cc:


Hello! I'm not sure this is a problem, it's more a case of bad usage practices on my end, but perhaps something that count be addressed.

I'm using post_types to create sections on a blog. For example, you could create a Yahoo Answers type forum by creating a post type named "questions". I named it in the plural because I want to have a nice permalink style, so I created a page named "questions" and some sub-pages like "most-recent", "most-commented".

In this case however, the template pages used by wordpress are a bit mixed up. page.php is used to display the main section page, which is , single.php is used to show a question single post,, but for subpages, index.php is used, while it should be page.php.

I did not check how the function works, but I am guessing that since there is a post_type named "questions", wordpress assumes that "most-viewed" is a post as well. When it doesn't find it, it falls back on index.php.

Again, I think this is probably not good practice, I'm just bringing this to attention so maybe I can help a bit.

Change History (5)

#1 @Denis-de-Bernardy
14 years ago

  • Component changed from General to Template
  • Milestone changed from Unassigned to 3.0
  • Severity changed from normal to major
  • Summary changed from post type and page name problems to it's unclear which template file is used by custom post types
  • Type changed from feature request to defect (bug)
  • Version set to 3.0

Rephrasing this a little bit:

It's unclear which template file is used by custom post types, and how to override them.

Suggestion: we use a file named after the post type (e.g. "custom-type.php", for one whose type is "custom_type").

#2 @nacin
14 years ago

See also #12105

#3 @danielpataki
14 years ago

Wow, I may have actually contributed :) Thanks for phrasing it better. and I think ticket:12105 does cover this more concisely.


#4 @Denis-de-Bernardy
14 years ago

  • Resolution set to worksforme
  • Status changed from new to closed


@daniel: can you add a note in codex somewhere? don't forget to highlight it's 3.0-specific.

#5 @nacin
14 years ago

  • Milestone 3.0 deleted
Note: See TracTickets for help on using tickets.