When you get started with WordPress there are so many themes that you don’t think you could ever run out of themes that would work perfectly for you. The longer you use your site you’re bound to come up on some kind of problem or need that the theme you LOVE just cannot accommodate. Maybe there’s a little too much space between some elements, or a custom plugin you’re using doesn’t look right. You want to fix it yourself and that’s great! No better way to learn than to do.
But you have to do it right.
What is a WordPress child theme?
A WordPress child theme is a custom theme that you create that is based on a “parent” or existing theme. It’s the easiest and proper way to add changes to an existing theme you like. Making changes to the child theme will reflect on your website but allow the parent theme to update properly and ensure that you can find any changes that you made to the theme in the future.
Not using a WordPress child theme can cause heartache. You dedicate a lot of time to customizing a theme and then you get a message saying that you need to update it, you just click update. All the work you have put into your customization is gone! All the files have been replaced with updated files for the original theme and you will have to re-customize all of those files. Not updating a theme because of changes is just as dangerous and can leave your site open to security problems and attacks.
WordPress uses the instructions in a child theme first and then goes to the parent theme’s files to finish the job. It keeps your code and changes separated in case you have a need in the future to remove them or change them. It keeps your changes safe from updates.
Is it hard to create a WordPress child theme?
Not at all.
The only file a WordPress child theme has to have is a style.css file. This file is where you will name the child theme, give it other information, and most importantly tell the child theme which theme is it’s parent.
You need access to your file structure either using FTP or another file manager.
Ok, let’s make a WordPress child theme!
First thing’s first.
1.) Navigate to your themes directory : wp-content > themes
2.) Create a new directory – name this directory based on what you want to call your WordPress child theme. For example you may want to call it “mytheme”.
3.) Let’s create our style.css file. Start a new text document and we will put in the required information :
Theme Name: MyTheme Name
Description: Wordpress Child Theme based on TwentyTwelve
Author: Your Name
Author URI: http://taterkakes.com
/* =Theme customization starts here
The @import line is what tells the child theme who it’s parent is. Use the folder name of the theme you want to make a child of instead of “twentytwelve” (unless of course you’re basing your new theme on Twenty Twelve). You may change the other commented lines to suit your child theme.
4.) Save your file and move it to your child theme directory that you created in Step 2. Be sure when you save your file that you don’t save it as a text document. You will need to Save as… and type style.css. If it asks if you are sure you want to change the extension, you are sure. If your document is not a CSS file your child theme will not work.
5.) You can activate your WordPress child theme! Right now you don’t have any CSS changes in your child theme files so it will look exactly like the original parent theme. That’s ok, you can still go to Appearance > Themes and you will see your child theme in the list.
If you don’t see your child theme listed verify all the previous steps and check again. Activate your new theme and WordPress will begin using your files in addition to the parent files.
What else can I do with WordPress child themes?
WordPress child themes are not just limited to the style.css file. You can copy other files from the parent theme (like single.php that displays a single post) and make your changes to the copy in your child theme. Use the same file structure as the original parent theme and any files you edit in your child will take priority over the parent theme files.
You can create a new functions.php file to add your own custom functions. Maybe you want your own shortcode or a custom dynamic copyright. Make your functions.php file and add your functions. NOTE: You do not have to copy the parent’s functions file. Start with a blank file. Your custom functions will run in addition to the parent themes functions.
The best part is if you mess up, remove the file you were working on in your child theme and it will go back to the original parent theme file. Copy the file over to your child theme and try again!