Theme Inheritance

When I first read about WordPress child themes on the wp-hackers mailing list, I wondered why I hadn’t realised that feature existed. One reason it hasn’t been more widely publicised is that it wasn’t, as it stood, terribly useful. All it allowed you to do was use the templates of one theme (the parent theme) and the stylesheet of another (the child theme). You couldn’t use it to create a child theme which inherited most its template files from its parent theme, but overrode some with its own files. That has now been remedied.

Consequently, in WordPress 2.7 it will be possible to write child themes which add new templates, and override existing ones in the parent theme. This has drastic implications; Ian Stewart, who proposed the patch, thinks it “may change everything”. It makes it much easier to create new themes, yes, but even more radically, it allows users to modify existing ones without changing their code. They can modify their Tarski installations to their heart’s content, while still being able to take advantage of bug fixes and improvements.

New templates

Tarski doesn’t come with a template for the Clean Archives plugin, although it used to, and one is available from Tarski’s svn repository. But if you add it to your Tarski directory, you might forget to back it up when you upgrade (I’ve done this a few times). So you create a child theme, which inherits from Tarski, and includes the Clean Archives template—which will automatically appear in the list of available page templates.

Overriding parent templates

One thing a couple of people have requested in the past is more comprehensive author templates for Tarski, with photos, contact details and so on. I’ve been loathe to add this, which leaves people in the position of having to hack the template, and then try copy their changes into the new template when they upgrade Tarski—or worse, not upgrade at all. With a child theme they could just copy Tarski’s author.php template, make their changes, and override Tarski’s template with their own. They could then upgrade safely without having to carry any changes across.

Frameworks

Greater possibilities are now also opened up for treating themes more like frameworks or plugins. Perhaps you love Tarski’s feature set but hate the layout. Simple: keep the options page, the navbar selector, the numerous templating functions, but write your own templates. We may see themes that are more of a code library than a set of templates.

No doubt there are plenty of applications I haven’t even considered yet. It’s time for your imaginations to take over: download the trunk version of WordPress, and start hacking.

Last updated 13th Jan 2009

, ,

1 response

Hi Ben, first thanks sooooooooooo much for Tarski, it more than rocks. The built in customization options are awesome.

I’m just starting to play around with the concept of child themes, also looking forward to the release of WP 2.7.

This is a huge step forward for those of us who are stronger at design & graphics than coding. Later…

~ marti garaughty