For a long time, theme frameworks have been the primary alternative to building things from scratch in WordPress, and to a lesser extent, starter themes. There is a better way.

Starter Themes & Frameworks

Starter themes work on the paradigm of adding and replacing. You’re given a theme that represents the ‘halfway’ mark and add what you need to it, and replace the parts that don’t.

Frameworks are essentially extended starter themes that provide you with a way of doing things, and a sizeable API and library through which to do them that’s intended to save you time. Examples include Genesis, Hybrid, _s etc..

These ways of creating themes I will term development from foundations.

The problem here is that what you want to build doesn’t always fit the foundations provided. You have to kludge your theme to fit into the frameworks way of doing things, and make do with the trade-offs and design decisions that the framework made, trade-offs that were made for the generic case, not yours.

Theme Modules

Some have tried to get around this by trying to implement module systems. A starter theme comes with a large number of component modules which are then selectively included via a module loading mechanism.

While this is an improvement, it’s an incomplete form of the actual solution. This is because the module loading and bespoke module collection is a very loose albeit more flexible form of foundation, and one is still limited by which modules are available and their inclusion.

Composition Rather Than Framework

The alternative, is composition. Instead of building on top of something, take parts that already exist, and assemble them lego style. This way you write the glue that binds them together, rather than creating pieces to fit into predefined slots, and you can assemble them however you like.

To aid me in doing this I’m going to rely on the power of Composer, though tools such as git submodules or svn externals could be used.

In my scenario, I pick and choose packages that provide things I like, and then bundle them into my theme. I then initialise them in my functions.php and let the tools do the rest.

Imagine I did the following:

require: { "rarst/meadow": "*", // TWIG based templates "scribu/theme-wrappers": "*", // scribus theme wrappers "tomjn/theme-common-styles": "*", // a class or two that add some styling I use a lot like the left align images etc "tomjn/youtube-white": "*", // I like white youtube embeds, here's a class that adds those "humanmade/Custom-Meta-Boxes": "*", // maybe I like their metabox API "cftp/responsible": "*", // adds a responsive tester to the admin bar "foobar/gridsystem": "*", // some css/less grid system "icit/wp-less": "*" // a LESS stylesheet plugin }

Followed by a brief bit of code in functions.php to set those up

<?php // autoload all our things require 'vendor/autoload.php'; // set up Meadow for TWIG templates $meadow = new \Rarst\Meadow\Core; $meadow->enable(); WhiteYoutube::start(); // something like this for example youtube class \tomjn\common_styles::add(); // add in common style stuff // etc...

Then I can immediately start using things such as using index.twig instead of index.php , or en-queuing LESS files directly. Composer will load it all auto-magically so I don’t have to require and include files.

Or you may have no interest in any of those and decide to pull in completely unrelated libraries, perhaps one that provides helper functions for loading images etc The point being that you can pick and choose what you want and how much you build yourself, without being forced to do it one way or another.

A real world example is Rarsts’ Hybrid Wing theme:

"require" : { "php" : ">=5.3", "composer/installers": "~1.0", "rarst/hybrid-core" : "~1.6", "rarst/locate-vendor": "~1.0", "twbs/bootstrap" : "~3.0", "pimple/pimple" : "~2.0", "rarst/meadow" : "dev-master" },

Here he pulls in Twitter Bootstrap and Meadow for his front end templating, then locate-vendor , the hybrid-core framework, and pimple, to structure his themes internals. He can also specify the versions that he wants.

Going forward, this is the only reliable way of doing things. Frameworks will always have disadvantages, unnecessary baggage, and complexity of some sort weighing someone down. Instead, assemble what you need and glue it together instead of trying to make what you want fit into pre-prepared slots.