Imagine tweaking your WordPress theme for hours, aligning those images, increasing line height so text is easier to read, setting that call-to-action button color, making featured images bigger… Weeks later you see there’s an update for your theme. You hit that Update button and BAM, your site’s a soup. Things are misaligned, sidebars look awful, images overlap, everything’s a mess.
If you’re using WordPress as your CMS of choice, it’s important to allow the parent theme to be updated easily without compromising your website looks and functionality. Creating a child theme is the easiest way of modifying your WordPress theme. But, not everyone needs a child theme. If you’re running a custom WordPress website, then you probably don’t need a child theme and all changes should be dealt by the developers.
Public WordPress templates, on the other hand, get bug fix updates and other upgrades, so your site may not look the same when you hit that “update theme” button. WordPress best practices suggest you should never modify the theme files directly. Or you can create a child theme. A child theme inherits all the genes from its parent, but still allows you to override them in terms of functionality and styling.
Pros of Using Child Themes
Everything has an upside and a downside and child themes are no different. The only downside of using a child theme is it may take a couple of minutes to create one, but you get much more for the time you invest:
Parent is always your fallback
Working with WordPress child themes is safe, because you have a parent to rely on. Should you do something wrong, miss a line of code or don’t like how it turned out, you can always fall back to the original.
Life doesn’t grant you with the luxury of choosing your parents, but WordPress does. While it’s easy to edit the look of the parent theme using child themes, be sure to do your research and choose parents wisely. Default WordPress themes are always a good starting point: Twenty Eleven, Twenty Twelve or Twenty Thirteen.
Updating without worrying
“A WordPress child theme is a theme that inherits the functionality of another theme, called the parent theme, and allows you to modify, or add to, the functionality of that parent theme.” ~WordPress Codex.Your child theme holds all the custom changes you’ve made, so updating its parent theme should be pretty secure. You’ll minimize the chance of ending up with weird styling after hitting “update theme”.
The modifications you’ve made are safely stored within your child theme, so it’s similar to creating a backup of your website.
Extensibility – Style & Functions
If you choose a good parent theme with a solid framework, you have a lot of flexibility without writing tons of code. You’ll only need to modify just a few lines of CSS to get what you want. It radically decreases the development time and this may be a good opportunity for you to learn a couple of WordPress tricks.
How to Create a WordPress Child Theme
If you’re willing to give it a try, there are two ways you can create a child theme and both are pretty simple. One involves plugins that automatically create child themes for you and the other method is to do it manually.
Use Plugins
There are several plugins you can find in the WordPress plugin repository:
The method where you use plugins is convenient, but you don’t get all the control. It will work for most beginners and businesses that don’t want to spend too much time dealing with child themes and customization.
Use Child Themes Manually
If you decide to manually create a child theme, just follow the list below.
- Create a directory in your wp-content/themes/ directory to hold the child theme. Don’t use spaces when naming the folder.
- In the child theme directory, create a file called style.css. This is the only file required to make a child theme.Here’s an example for Holi – Twenty Thirteen’s Multi Colored Child Theme. The style sheet starts with the following lines:
@import url("../twentythirteen/style.css"); /* Theme Name: Holi Theme URI: http://thematosoup.com/products/twenty-thirteen-multi-colored/ Description: Multicolor child theme for the Twenty Thirteen theme Author: ThematoSoup Author URI: http://thematosoup.com Template: twentythirteen Tags: blue, gray, green, yellow, pink, purple, red, brown, orange, tan, white, yellow, light, one-column, two-columns, right-sidebar, flexible-width, custom-header, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, translation-ready Version: 1.0.4 This theme and all bundled resources, like WordPress, are licensed under the GPL. Use it to make something cool, have fun, and share what you've learned with others. Header/BG Images License Author: Slobodan Manic http://thematosoup.com License: GPLv2 */
You are allowed to change any of these lines as you see fit. The two mandatory ones are Theme Name and Template, which is the directory name of your parent theme.
In the case above, the parent theme is the TwentyThirteen theme, so the Template is twentythirteen, which is the name of the directory where the TwentyThirteen theme is located.
If you don’t import parent’s stylesheet (style.css) which is done by this line:
@import url("../twentythirteen/style.css");
you’ll erase the identity completely, but we don’t want to do that – we want only to make a few adjustments. This “gene import” must be before any additional CSS you wish to include.
You can then activate your child theme in Appearance > Themes.
How to Change More than just the Visuals
Want to alter more than just the looks? Just copy the file you want to edit in your child theme. So, you can for instance take header.php from the parent to the child and edit it there.
For more information on how to do edit theme files, deal with localization, functions.php and other stuff only developers will need, take a look at the WordPress Codex on Child Theming
For end users, the biggest benefit of using child themes is that updating the parent theme almost never results in unexpected malfunctions. Also, all customization work is safely preserved.
WordPress Best Practices suggest that themes and plugins extend WordPress by overriding its core. Child themes are no different, so use them whenever you can and make your WordPress based business more secure, easier to maintain and extend.