What is a child theme and why should you create one? The simple answer is that you probably want to some make changes to your website but you don’t want to lose the changes you applied when you update the theme.
Creating a child theme inherits all the code from the parent theme which allows you to modify any file and keep these changes without getting overwritten when the theme gets updated.
You will need to have access to your site files, this is done via an FTP client ( use FileZilla it is free!)
You can create a child theme in only 3 simple steps:
- Create a child theme directory, and with that I mean create a folder inside wp-content -> themes. By convention the folder name will be your theme name-child, For example if you creating a child theme for the twentysixteen them the folder name would be “twentysixteen-child” .
- Create the style.css file for your child theme, simply open notepad and paste the below code. Save the file the name styles.css. This will inherit all the parent theme styles to the child theme. All what is left now is to upload this file to the child theme folder that you have already created.
- Theme Name: The child theme name that will show on your WordPress dashboard.
- Description: This will be displayed in your theme details.
- Author: Your name or your companies name, since you are creating this child theme.
- Template: This needs to be the directory name of the parent theme, an error message will show up if this is not correct.
- Text Domain:This should be the slug of your theme, it is important for internationalization (making your theme translatable.)
- @import url(“../twentysixteen/style.css“);: The diroctory of the parent theme css file, that will be inhereted to our child theme.
Now you can make changes to any of your theme files by copying and pasting it to the child theme directory. Open the file you copied, apply your modifications and they will be kept safe!