Modular themes: Apply template hierarchy to folders within a theme
|Reported by:||koopersmith||Owned by:|
Applying template heirarchy to folders within a theme will allow themes to be broken into modules, allowing theme developers to substantially reduce repeated code. This is an automated, complete version of the use of get_template_part() in Twenty Ten.
Based on my tests, these functions should cause no noticeable difference in performance.
The patch has the added benefit of creating an accurate global $wp_template_hierarchy object (and a getter method), so any plugin/theme can access the template hierarchy for $wp_query.
The patch introduces several new functions: get_template_module($folder), get_template_hierarchy(), update_template_hierarchy(), and 2 private functions.
Finally, the patch also add a 'locate_template' filter on $template_names at the beginning of locate_template(), and turns the large conditional in template-loader.php into a function: template_loader().
Change History (53)
- Component changed from Template to Themes
- Type changed from enhancement to feature request
- Version set to 3.0
comment:2 @koopersmith — 5 years ago
- Summary changed from Modular themes: Apply template heirarchy to folders within a theme to Modular themes: Apply template hierarchy to folders within a theme
- Keywords has-patch added
- Milestone changed from Unassigned to Future Release
comment:30 follow-up: ↓ 33 @scribu — 4 years ago
comment:32 @gruvii — 4 years ago
- Cc gruvii added