Opened 16 years ago
Closed 15 years ago
#7086 closed enhancement (fixed)
Look for Template Files in Stylesheet Directory First
Reported by: | ThemeShaper | Owned by: | westi |
---|---|---|---|
Milestone: | 2.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | has-patch needs-testing |
Focuses: | Cc: |
Description
PROBLEM: I can make new, CSS-only, child themes by including "TEMPLATE:
define-parent-theme-here" in the comments of my stylesheet, inheriting all
the page templates of a parent theme. I can override and add new functions
by including a functions.php file with this child theme. BUT! What if I want
to add new page templates? Can I add foo.php or bar.php in the folder of my
child theme and make it available in WRITE > PAGE?
Nope, I can't. WordPress Should change this.
EXAMPLE:
sandbox ..header.php, sidebar.php, etc. ..links.php ..archives.php
Links and archives are existing custom template files
child-theme ..style.css ..functions.php ..foo.php ..bar.php ..header.php
foo and bar are new page templates that should become available in WRITE > PAGE when child theme is the active theme—but they currently don't. Plus, WordPress should use the header template from child-theme.
BONUS: Why would I want to do this? More custom themes, less work.
A blog is a blog is a blog: most custom theming work happens on the home
page. Make a new home-page.php file in a child theme and with some fun CSS
and javascript you can make a host of easily maintained themes; most of the
code is recycled from the pristine "parent theme". Imagine a hundred clients
with drastically different sites, all with easily upgraded code: overwrite
the parent theme, tweak home-page.php. Done.
This should also add a lot more options and possibilities to the coming
WordPress Theme Marketplace, speeding up theme vetting (most of the code
being inherited from The Sandbox) while providing some even more
dramatically new variations.
Attachments (9)
Change History (22)
#2
@
16 years ago
ionfish: I echo your preference for checking for the same file in the parent before moving to the next file in the child.
#3
@
16 years ago
I've probably attached these files incorrectly. Please forgive. I'm new here.
Anyway, the patch was coded by Kristin Wangen (http://wangenweb.com/). Child theme Template files can override parent theme files now. Unfortunately, neither one of us can figure out how to get new template files recognized. Anyone?
#4
@
16 years ago
To be more specific; the trouble we got is that if you put a new custom page template into a child theme, the page template picker in write -> page don't "see" it.
The same goes for the theme editor, it only shows the template files for the parent theme.
I think it's tied up to $themes[$theme][Template Files] which both codes uses, but I'm not sure how to get around it.
#6
@
16 years ago
- Keywords has-patch added; needs-patch removed
I've tried to upload new diff files based on the files from 2.6 RC1.
But I have still not figured out how to make WordPress recognize custom page templates in Child Themes.
#9
@
16 years ago
- Keywords needs-testing added
Updated patch, should now allow the use of custom page templates from both themes, as well as editing of same.
#11
@
16 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
A fix is needed for get_themes() which will now set a theme's 'Template Dir' to the name of the directory which happens to contain the first-listed file.
#12
@
16 years ago
Not sure exactly what the patch achieves here.
Doesn't it just pick a different arbitatry file to get the directory from?
The category template can exist in two forms: a generic category.php file, and a category-$cat_id.php file. A number of other template calls follow the same pattern. What should the order of precedence be?
The child theme's category-$cat_id.php should clearly be looked for first, and the parent theme's category.php file last. However, it is not obvious which of the other two variations should take precedence over the other: the child theme's generic category.php file, or the parent theme's specific category-$cat_id.php file. My preference would be for the latter, but there may be dissenting views.