Are you using WordPress and not aware of the WordPress Child Themes?
Are you making changes every time with your theme when it is updated?
Then it’s time to know about the WordPress Child Themes.
WordPress developed the concept of parent/child themes and integrated it into the core specifically to take care of theme upgrade and customization issues. Theme frameworks like Genesis are based on WordPress’ child theme feature.
Now a child theme is one of the simplest things to grasp on WordPress, so there’s no reason to frown like that. A child theme, as defined by WordPress, is “a theme that inherits the functionality of another theme (aka parent theme).”
Let’s simplify this even more:
What is a Child Theme?
Essentially it’s just a theme based off of another complete Theme. Think of it as a paint job over a car (credit goes to Studiopress for the analogy). The default car, with all its features and interior (as manufactured), is the parent theme. The modifications made over those, without irreparably changing the default car (new paint, alloy wheels, seat warmers… Wow I’m getting off topic) is your child theme.
The minimum requirement for a child theme is a directory (theme folder) named after the parent theme, and consisting of two files – style.css and functions.php. Other files can be created with the same name as parent theme if you want the child theme to override those files in parent theme when processed.
Why Use a Child Theme?
You like your current theme, but you wish it could do a bit…more. You want to jazz it up your way, or maybe add some features/code snippets to it.
That’s when child themes come into play.
While making those same changes right within your original theme files would be your first instinct (cut out the middleman, in this case – child theme, so to speak), those changes will be overwritten anytime the theme is updated.
A child theme, on the other hand, gives you an ‘overlay’ to work with while preserving the integrity of your original Theme.
It’s also a good time to mention that while learning WordPress theme development –child theme customization is an excellent way to start.
How to Create a Child Theme?
- WordPress installation (Duh.)
- Access to FTP
- A text/code editor like Notepad++
You can also use a plugin like One-click Child Theme if you are not able to access your WordPress installation directory.
For those of you who can use the FTP client:
- Go to your WordPress directory
- Access path /wp-content/themes
- Create a new folder (directory) and name it after your parent theme (the one you intend to customize). For instance, if you are creating a child theme for TwentyFifteen, create a new folder called TwentyFifteen-child. This is because WordPress can recognize the child theme and load the changes you have made in the child theme. Do not use any spaces in the name.
- Create two files with your text editor, namely CSS and functions.php. Save them both in the child theme folder.
- Technically, you are done creating a child theme!
How simple was that, right?
Now check out the great tutorial on editing WordPress child themes to do with the theme as you please.
Some Words of Advice (about WordPress Child Themes):
- Make sure to enqueue your parent theme’s stylesheet (CSS) file if you are happy with most of the style but only need to make a few changes. Use wp_enqueue_scripts function in child theme’s functions.php. For parent themes that have more than one stylesheets (and if you want them all) use get_template_directory_uri() function as directed in the tutorial.
- Child themes may cause compatibility issues with parent Themes, although it’s very rare and usually happens after the parent theme is updated with different CSS selectors. Use Firebug to find them and update your child theme accordingly.
- If you have already made changes in your original theme files, you need to download a fresh copy of the Theme, compare the two and put the customized files in a child theme folder instead.
Keep the Codex open in a tab at all times, just to have a reference point.
And if you are having any issue or problem with the WordPress Child Themes, let me know through the comments, and I will be there to help you.