No Children Necessary

This post is dedicated to Michael Fields, who donated to help me get to WCSF. I envy him his Portland.

All Children left unattended will be sold to the circus.Not all of my sites use child themes. In fact, most of them don’t. I work on about 20 WordPress sites and of them I have five child themes, one of which is an unedited child from the theme dev. Even when I have custom-post-types, I rarely need to mess with a child theme, unless it’s needing a special template or page design. That means that most of my child themes are a style sheet, a functions file, and one or two new pages. When I do have to make a child theme, I do my best to make it reusable as much as possible. I have the same child theme on two sites, but they look nothing alike.

But generally, when someone tells me they need to edit a theme, I tell them how to make a child theme, which I fully endorse, but also to step back. Do you really need a child theme? See most people make a child theme to customize their site, and since that’s pretty much what they were invented for, it shouldn’t be a bad thing. But sometimes people are using a child theme for the wrong thing and they ignore all the built-in ways to customize a theme.

The only reason you need to use a child theme is when you have to add a new template, or replace one that cannot be hooked into.

That’s it.

Before we get into this, I’m going to point out that if you are using a Theme Framework, this is not for you. A theme framework is something designed for you to build a child theme off of. This post is for people who use TwentyEleven and want to make it a little special, or even a lot special, because most of what you want to do is something in CSS anyway. Yes, I did just say most of what you’re doing with a child theme can be done with CSS. The rest of it can usually be done with widgets, and after that there are some plugins to help you out.

Ready to customize your theme without a child theme? Here we go.

Themes Have Options

It’s 2012, and the majority of themes have options. Some have too many, but pretty much every theme has some options. The default theme has some basic options. People may call them simple, but these options are huge to make your site just a little different. A single column, no sidebar, TwentyEleven is automatically a different feel than the generic sidebar site. It puts the concentration on your content, which is king, and pulls it back to the importance of it. If you’re running a documentation or essay site, that’s what you want. Most themes also have header options, to pick your text, color, and image, as well as background images and colors. The new theme customizer lets you actually do almost all of that in one go, making it even easier.

Remember. All cars have wheels, windows, and doors: it’s how they’re arranged and styled that attract most people.

I know I said I wasn’t going to mention Theme Frameworks, but themes like Genesis, and even ones like Hybrid, often build their themes with powerful options that let you use them without having to make your own functions files. More on how you don’t need that later.

It’s just CSS

No Children AllowedMost of what people want to change is CSS. I said it before, I’ll say it again. If you want to change the color of your site, and it’s not included in the theme options, you want to end your CSS. But how, I hear you ask, without a child theme? WordPress.com Custom CSS (aka Safe CSS) will let you edit your site’s CSS without making a child theme. You can’t use all CSS, there are some moz-radius things that don’t seem to work, but other than that, you can totally change up your site.

CSS is more than just colors. CSS can format your text, move your divs, and completely customize your layout, all with just a few lines. Change the one column from a skinny one to a fat one, indent your paragraphs, and add whitespace to your header without any text. Everything can be moved.

Neglect not your menus

Customize your menus. You can add images and styles to your menus, and you should to make them look like anything you want. Yes, this goes back to CSS, but you’d be amazing how many people just leave them alone. First, remember to customize your menu to look like anything except that list of pages. Change it up right away, and then add in design and style to stand out. The menu is supposed to catch your reader’s attention and direct them where you want to go. Don’t slack off.

Widgets, Widgets, Widgets, Widgets, Widgets, Widgets, yeah!

Do not ignore the power of your widgets. Your widgets control your sidebars in most sites, but also your footers. People think of them as just a way to toss in twitter and search. You can use the amazing, incredible Widget Logic to control when and where a widget shows, to make different pages show different information. An alternative, if you’re really good at php, is the impressive PHP Code Widget, which will let you put any PHP in widget and customize it on it’s own.

The most powerful widget in your arsenal, however, is the text widget. Text drives your site in so many ways, a simple text widget can hold any information, from contact information to a haiku. You can put anything in a text widget, HTML, inline CSS, your special code. Text is insanely powerful and you shouldn’t forget it.

Want to use shortcodes in your widgets? We can do that too with two lines of code:

add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode', 11);

Normally this would go in your functions.php in your theme, but hang on, we’ll get to where to put that in a minute.

Conjunction Junction, Don’t Use Functions

Here’s where a lot of people demand they have to use a child theme. They need to add in functions, like the overriding filters and actions in their parent theme. I very, very, rarely use a functions.php file in any child theme, because I hate having to replace them if I ever switch themes. Instead, I make use of mu-plugins.

Generally I end up with three files:
customposttypes.php
functions.php
themename.php

Unattended children will be given espresso and a free kittenObviously, the first one is for my Custom Post Types. They all live there happily. The second is for anything and everything I’d put in that theme function file. It’s important for me to keep the general functions separate from the theme specific ones, however. In fact, while I originally said I made a ‘subchild’ theme for Genesis’ Balance theme, I’m now using the CSS (mentioned above, SafeCSS), and two MU plugins: ipstenu-functions.php and ipstenu-balance.php. That’s right, all my tweaks, everything I did, are there. I’ve done the same for this domain, and all other sites except for photos. Why? Photos has a CPT that needs a custom template.

On subsites of a network, I wrap my mu-plugin with if ( $blog_id == 2 ) { ... } to ensure it only gets called on that subsite. For the theme, $theme_name = get_current_theme(); and if ( $theme_name == 'Origin' ) { ... } within. Be careful, the theme name is the name, not the slug, so ‘Balance Child Theme’ and not ‘balance’ is what you want. Even straight up theme related actions like add_action('genesis_before_footer', 'ipstenu_before_footer'); work without a hitch. That leaves me with (at most) three ‘plugins’ for each site, and usually not even one. If I wanted to be really lazy with Genesis, I could do most of it internal with a plugin to do it on the dashboard instead.

You can do it all without children

Really the point is that of all the children theme possibilities on this network, the only one that exists is the one that needed it’s own special template. I certainly wouldn’t do this for all sites, but once you pull all the theme specific data out of your functions file, there’s often very little left. When you can do this, you retain a little extra flexibility in that your changes are easy to swap out between themes.

At the end of the day, it doesn’t make things easier or harder, just different.

Put all your non-theme-specific changes into a mu-plugin. Put your CPTs into another. See what’s left. You may be surprised.

About these ads
StudioPress Theme of the Month

Comments

  1. I rarely use Child themes. I’ve always hacked at themes so viciously that I never saw the point in preserving the original.

  2. Amy Hendrix says:

    I like the approach and it’s a nice bag of tricks, although I’m not a fan of the mu-plugins piece — not because mu-plugins aren’t made of awesomesauce, but because the audience is wrong. The people who would normally be copy/pasting something into their functions file and need to be told to use a child theme instead are rarely very big fans of using ftp and a text editor; they want to use the theme and plugin editors in the admin because they’re intimidated by anything else.

    I’m lately a big fan of Pluginception: we’ve all been advocating custom functionality plugins over the theme functions file for a long time now, but they run into the same issue as mu-plugins for people who really want to use the admin for everything; why not steer those people to creating such a plugin inside the admin where they’re comfortable?

    • For those users, I would really suggest using a managed theme like Genesis, actually (which I need to write up about… I promised Andrea).

      There are different levels of WP users, and we don’t always do a good job of catering to all of them. I see this mu-plugins method as a great one for the mid-level/advanced group. Theme frameworks that offer everything on the admin end are perfect for the ‘just past beginner’, and real newbies should stick with using the theme as it’s given, only edit CSS please and thank you ;)

    • Amy Hendrix says:

      It may just be that we’re thinking of different audiences: I’ve been thinking a lot lately about better ways to counter the just-paste-it tutorial brigade, and while making it easier to make a plugin is a few clicks more than just copying, it’s still a lot easier for new or non-techy users to handle, and it might even be possible to sell them on some benefits they’ll see, like “hey, you won’t lose this when you change themes” and “if you do mess something up, you can deactivate just this plugin without having to unfuck the whole theme”.

      (I’m really looking forward to the Genesis post, btw — largely because I always feel like I’m not quite getting something. Like it’s really nice stuff, and clearly miles beyond the crap that usually makes me put “premium” in quotes, but I somehow missed a memo on why it’s the Best Thing Ever?)

    • Yeah, we need better new/non-Techy methods for these changes. Even pluginception is a horrifyingly complicated thing for the new. But how do we ease them in past the copy/pasta and into the “This is what the code is and how it works…”

      I love how PerishablePress explains things, with the long talk, and then the answer at the bottom, but that’s still something the new folks can’t grasp yet. We have things in place for ‘just use it’ and ‘Super ZOMG Unicorn Wranglers’ but not the middle so much :/ and not the beginning of the middle at all.

  3. I still have never used a proper child theme before.

    I see no problems with the theming system built into WordPress, ie: if you want to change something, make a theme. No need for child themes then ;) I figure that’s what the purpose of a theme is. IMHO child themes seem to be a layer of abstraction too far in most circumstances.

    • People who want all the power make themes.

      People who want to customize the power make child themes.

      People who want all the power, with options, make theme frameworks.

      People who want to use the power, use theme frameworks.

      There’s no one right way for themes ;)

    • Yup, that’s why I used the word “most” in my comment :)

  4. Sami Keijonen says:

    Interesting points and it really shows how many different ways you can modify your site.

    One question. If I make my CSS using WordPress.com Custom CSS does it save CSS only for current theme? I mean if I change theme, I need to modify CSS again. And after couple of months I decide to change back to original theme, are my original CSS saved so I don’t have to start all over again.

Half-Elf? Try Half OFF WordPress ebooks!