I’d like to create a WordPress theme using only some of the template files. Unfortunately, when it comes to theme inheritance, it seems that WordPress allows you only two choices. Your custom theme:
- may contain a stylesheet and images, this “theme” then inherits all of the template files from another theme, or
- must contain a complete set of template files, which is, at its most minimal, style.css and index.php.
Apparently, there is no way to create a theme with a partial set of template files. Adding the line “Template: default” to the theme header section of a custom stylesheet will allow that theme to inherit all of the template files from the default theme, but it will also cause WordPress to ignore any files in the custom theme.
In my opinion, there should be an option to make WordPress fall back on the default theme when an expected file isn’t found in a custom theme. A custom theme could then contain only those files that have been modified from the default, so that future changes any unmodified default theme files are automatically inherited by the custom theme after upgrading.
The argument against this type of behavior is that, should the default theme be radically changed, it’s possible that such inheritance will result in a broken custom theme. This is a valid concern, but since I’ve been using WordPress, the files of the Kubrick theme haven’t changed in such a way as to break as a result of this inheritance.
I’m hoping that someone out there has come up with a way to change this behavior and make the themes degrade gracefully. According to Ryan Boren‘s post on the wordpress.org support forums…
You can’t pick and choose certain files to inherit, you must inherit a full set of templates. It’s an all or nothing deal. For awhile we did allow individual inheritance, but it confused the hell out of people and was a bit too heavyweight during page load since the code had to go looking in multiple locations in order to put a theme together. That’s why I call themes that inherit templates from other themes “stylesheet only” themes. They don’t have any templates of their own.
As a possible solution, I suppose one could use PHP includes in otherwise empty template files to include the default files.