Sass, Bang, Wallop! (compiling CSS for WordPress child-themes)

Re-post from Aptivate‘s Blog:


The long version

Sass setup

We’re writing our stylesheets using Sass because writing CSS is more fun with Sass. And using the lovely compass to compile our stylesheets. Our compass config looks like this:

# config.rb (in wp-content/theme/our-child-theme)
css_dir = ""
sass_dir = "sass"
output_style = (environment == :production) ? :compressed : :expanded
line_comments = (environment == :production) ? :false : :true

So this means that when developing, we can run

compass watch

and our stylesheet gets compiled.

And when its time to deploy

compass compile -e production

and a minified stylesheet is produced.

WordPress setup

We were developing a wordpress site using a child-theme. I came to the project relatively late and have never built a child theme. So stuff was working when I got it and I just went about continuing development. I introduced the switch from CSS to Sass (we were doing some major styling overhaul and the stylesheet was at 2500+ lines so it seemed like a good time for an overhaul).


When we switched to staging, the site appeared to be fine, but there were a couple of small glitches and noticed in the back end that:

  • templates were no longer showing in the Page Attributes box (on the right when you’re editing a page)
  • the dashboard had a red error message “ERROR: The themes directory is either empty or doesn’t exist. Please check your installation.” where it normally mentions the theme.

Fixing it

Looking at the requirements for a theme in wordpress – an index.php and a style.css are needed. There was already a style.css (it was a beautifully minified, comment free stylesheet) but no index.php. So I (mea culpa) added an index.php. Horror, everything broke. Because with the index.php wordpress thinks that your theme is a theme. But our theme was a child theme and we were using things like TEMPLATEPATH which, when used in a child-theme points to the parent-theme directory.

So, that was bad.

Then found the wordpress page on child themes ( And remembered a post from Chris Coyier (my personal CSS hero) on Sass and WordPress themes ( and discovered that a single


could solve all our problems.

Our main Sass stylesheet that was doing all the imports looked like this:

Theme Name: Our Child Theme
Description: The description
Version: 1.0
Author: Aptivate
Author URI:
Template: parent-theme
@import "compass/reset";
@import "compass/utilities/general/clearfix";
@import "compass/css3";

@import "globals";
@import "original";
@import "pagination";
@import "header_search";
@import "solr_results";
@import "social";
@import "nav";
@import "home";
@import "footer";
@import "teaser";
@import "themes";
@import "map";
@import "video";

This assembles all of our smaller sass sheets into one stylesheet, with the comment at the top. When using the production environment variable for compilation, compass minifies the CSS including stripping out all the comments. This is usually a good thing, but we really need this one comment. By changing the comment from

Theme Name: Our Child Theme


Theme Name: Our Child Theme

then this one comment will not be removed and now our child theme is happy once more.

Sass, Bang, WordPress 😀

A view of Abbotabad

Abbottabad – now that was a surprise!

When I heard that Osama bin Laden had been killed in Abbottabad in Pakistan. I was, to say the least, surprised. Mason and I spent a night in Abbottabad in July 2007 while on Vacation in and around Islamabad. Our guest house had the most awesome bed we have slept in to-date. And I got bitten by a spider in the middle of the night and had an egg-sized bump on my forehead for a day or so. My lasting impression of Abbottabad was thinking how much it was like Tuscany, red tile roofs dotted among green hillsides. It has a pretty church which was being renovated while we were there. The lonely planet entry reads “Abbottabad, Hazara’s head-quarters and biggest town, was founded as a British garrison town in the 1850s and still possesses a colonial-era flavor. The shady gardens and wide streets in the Cantonment evoke the 19th century, and it’s not unusual to hear church bells or a military band.” Of all the places I’ve visited in Pakistan, this is not one of those that I could have imagined a precision US strike on the “world’s most wanted man.” The world is full of surprises.

IMeCA 2010

The IMECA 2010 conference has been a truly inspiring event. A great mix of sharing experiences from a wide variety of people who are trying many different things as well as a real eagerness to learn and an opportunity to bring new tools and ideas to light.  I hope this will be the start of me getting more involved in the region, but I now need to go learn Spanish!

The circus of life

(starting at ~0:50 if you want to skip ahead)
From the day we arrive at the office
And, unsuspecting, step into the mess
There’s more to see than should ever be seen
Way too much to ever address
There’s far too much to take in here
Stuff to find than is best left unfound
But the promises high
Made always on the sly
Keeps great and small on the endless round

It’s the Circus of Life,
And it screws us all
Through drama and hype
Through Skype at night
Till we lose our place
On the path of sanity
In the Circus,
The Circus of Life.

A contribution from a friend who will remain an anonymous genius…we’ve all had days at work that are summed up by this brilliant modification of an old classic.

checking in

a lot of data

means a lot of stuff, a lot of people, a lot of geeking, and cake!

cop on a segway

cop on a segway

probably the #1 reason why Lima rocked my world, other candidates included the very hot outfits they give to lady cops (what a great police force), ceviche, pisco sour, guinea pig, the best diet coke i’ve ever tasted, deliciously chill miraflores and a high prevalence of drinkable yoghurt and vintage cars

2010 openMRS

geeks and docs

2010 openMRS implementers meeting