Opened 3 years ago

Last modified 3 years ago

#13100 new feature request

category template matches ancestor category, single post matches category filename

Reported by: jredfern Owned by:
Priority: normal Milestone: Future Release
Component: Template Version:
Severity: normal Keywords: template selection
Cc:

Description

Dear wordpress developers,

There's two features which I think would be very useful in the wordpress template selection process. The first relates to categories - currently a category template file will be selected when the category of the selected post matches the filename of the template (category-catfoo.php). Because categories are hierarchichal (can be sub-categories) I suggest that if it can't find a template for the current category it should also also try to match ancestor template files.

The other feature which I suggest would be useful, is single post template matching using category names. For example, single-catfoo.php. This could also match on ancestor categories if none is found immediately (single-catrootfoo.php).

Best wishes,
Jim Redfern

Change History (3)

  • Milestone set to Future Release

comment:2   jane3 years ago

Hi Jim. The best place to make suggestions like this would be in the core features Ideas forum at http://wordpress.org/extend/ideas, so that non-developers can also weigh in. We try not to add feature request tickets in Trac until there has been some community discussion and there's a general agreement that it's something we should do, so that we can keep Trac focused on implementation rather than feature determination.

Note: You made two different suggestions in your ticket. Whether here or in the Ideas forum, it's best to create a separate ticket for each suggestion/bug report, so that they can be rated and/or handled effectively by the community.

I was able to achieve both types of matches using a few lines of code.

1) ancestor category template: This could cause significant overhead if you have deep nested categories.

2) single-cat template: This could cause unexpected results when a post is in multiple categories.

Note: See TracTickets for help on using tickets.