Generally beginners in WordPress will have questions like what is WordPress child theme ? and why should I create a child theme in WordPress ?.
If you have these kind of questions in your mind then today, in this article we will try to answer them. At the end of this post, we will also let you know the pros and cons of it in WordPress.
Child theme in WordPress allows you to make changes to your original theme. If you directly make changes to your original files instead of having it in a child folder then with the update to original files, all such changes will be wiped out. Updates can be for security reasons or to add some new functionality or to fix some of its problems.
Child theme in WordPress inherits the functionality of the original parent theme and presents it in a way with the changes that you specify in it.
Creating a Child Theme in WordPress
To get started, first install and activate your parent theme i.e. twenty thirteen in our case. Creating a child theme in WordPress will be similar to all type of other WordPress parent themes. As we have considered twentythirteen as our parent theme, we will be activating twentythirteen in our site.
If you do not know how to install and activate it in WordPress then please read our article on “How to upload or install a theme in WordPress”.
Now create a new folder and name it something. While naming your folder of child theme in WordPress, you should not have any space in between the name. To differentiate it from others we suggest you to add child to your parent theme’s name. For example in our case we have named it as “childoftwentythirteen”. If you have space in between the name then it will not work.
In that new folder create a .css file and name it as “style.css”. To get your site works in WordPress this is the first file that you need to create inside your child theme folder.
Inside the style.css file copy and paste the following codes;
Theme Name: Child for twentythirteen
Description: Twentythirteen child
You can make changes to the author section and other fields like description and name. But please remember the @import url and Template should not be changed if you want it to work for parent twentythirteen.
Instead of twentythirteen, if you have selected some other theme in WordPress then change it to that. You can find the template details in your original folder’s style.css file. In @import URL section you need to change “twentythirteen” to the folder name in which your parent files are stored.
Now your child theme is ready. You can make changes to redefine your site in WordPress.
To activate it, you are required to upload and install it to your WordPress site. After installing, activate it in WordPress. Please remember that it should be uploaded with .ZIP file. Installation and activation steps for child theme is same as in case of parent.
After activation, your WordPress site will look like the parent theme. You can make changes to the style.css file to give your site a different look. If you want, you can also add other function files to work it or present it differently.
To make changes to the content.php files or other different files, you can copy the original file and paste it in child folder. After changes to the files inside your child folder, the functionality of your site will change.
Pros and Cons of Child Theme in WordPress
- Updates are crucial when there is a security issue. You can customize an existing WordPress parent theme without losing the ability to upgrade by which you will always have a updated version. For example: Time to time twentythirteen will be updated for different reasons. If we make changes to the original twentythirteen theme then with the update, we will lose all the changes that are earlier made to these files.
- With the child theme you can extent the functionality without touching the parent file. The beauty is that when you do a mistake by deleting the function or file you can always get back to the original source file without affecting your site’s functionality.
- You can de-register any functionality which you do not like in your WordPress parent theme.
- While it’s easy to create a child theme, it’s very difficult to create it for a WordPress framework. To create it in WordPress for a complex theme or framework, you are first required to read different hooks inside it and then can make changes.
- Your parent theme or framework should allow you to build a child theme. There are certain WordPress frameworks and themes which do not allow creating a child theme.
At then end, we suggest you to use child theme only when you are making some changes to your parent theme. If you are making changes by using the option panel then you are not required to use it in WordPress.