Thord Daniel Hedengren - Smashing WordPress_ Beyond the Blog-Wiley (2014)

(avery) #1

CHAPTER 5 • The Child Theme Concept 125


EVENT CHILD THEMES
One of the cooler, albeit not as groundbreaking, usages of child themes is the possibility of
short-term event themes. Think about it: If you have a theme that you’re happy with but
suddenly want full of snow and reindeer and such to celebrate that cold time of the year, then
why not just create a child theme that swaps out the colors, background images, and even the
graphics?

Or, to be blunt, say you want to make money by selling parts of your design to a company for
promotion. Background images, slightly altered header files, and the like are all a breeze using
child themes. Sitewide ads and roadblock-like functionality are easily implemented in this way.

Using child themes for minor events, promotions, and other custom hacks is a great way to
keep the main theme clean. Any good theme designer will consider this option.

A Few Words on Theme Semantics


Child themes can certainly spin things around. Say that you love a particular theme, and it has a class
called column-right, which is used to place the ever-present sidebar to the right side of the main
content, in a suitable column. Fair enough. Problem is, you want it on the left side, which you can easily
fix by just applying float: left in the style.css file of your child theme. It works, but it is ugly to
have an element named column-right positioned to the left.


This may seem a bit nerdy, even trivial, but writing code that makes sense is important when several
people are collaborating on a project, and also good form in general. The whole point of naming
elements in design after what they actually are supposed to be is that you, and the people you work
with, will have an easier time finding your bearings in the design.


So column-right should really be on the right side. That’s where you’ll look for it, thanks to the
name.


Another popular example of this is the sidebar. A lot of people think that the sidebar.php template, or at
least the actual term sidebar, should be retired. It is something of a relic from the past, from the time
when WordPress was about blogging only. Today WordPress is a CMS, and you use it for a lot more
than just publishing blog posts. Why call it sidebar; why not sidecolumn? You can take the reasoning
another step; what says that it will be on the side of things at all? Single-column designs often position
the sidebar.php content at full width below the main content, above the footer. There’s nothing wrong
with that, other than that the sidebar obviously isn’t to the side.


Now, perhaps that’s taking it a bit too far. WordPress and its community will most likely keep using the
sidebar lingo for quite some time, but that doesn’t mean that you need to name things column-right.
It is something to think about when designing themes because although a certain name may make a lot of
sense in the present context, there’s nothing to say that you won’t be moving that column-right to
the left side. And if someone were to use your theme as a parent template theme for a child theme, that is
even more likely to happen.


So think about the semantics. It’ll make things easier on everyone.

Free download pdf