There are times when you need to make changes to your theme that requires modifying theme files. If you were to modify a theme file and an update comes along, you will lose your changes because the update overwrites the theme files.
To reiterate what the WordPress.org website describes why you would want to use a child theme:
- If you modify a theme directly and it is updated, then your modifications may be lost. By using a child theme you will ensure that your modifications are preserved.
- Using a child theme can speed up development time.
- Using a child theme is a great way to learn about WordPress theme development.
You can refer to the WordPress Child Themes for the full details of creating your own child theme.
Will You be Making Changes?
One thing to consider whenever you are setting up a website, or even if you have an existing website on WordPress, is whether or not you plan to make custom changes. Even if you are not 100% sure right now, it’s something you may do later in time, so I recommend that you give this some serious thought.
Whenever you decide to use a child theme, it means you have to deactivate your theme and activate your child theme. WordPress will see this as a new activation, therefore, you may have to redo all your settings, options, and maybe even widgets. If your website is already established, styled, and many widgets are being used, this makes for a nasty time to put everything back in place and to redo all your option settings.
If you start with a child theme with the possibility that you may customize your theme later in the future, I recommend you start with the child theme right away to avoid the hassles of going back and redoing everything later.
Child Themes Needs a Parent Theme
Before you use a child theme, it’s important to ensure that you have the parent theme installed in your website. It does not have to be active, but it does need to be installed. The child theme will be the one that you activate.
The reason for the need of a parent theme is so that the child theme can inherit the features and functions of the parent. This is important because a child theme is generally going to start out as a blank theme that is waiting for your custom modifications to be added to it. In a sense, because it inherits all the functions of the parent, you are simply adding new functions and styles.
Updating Child Themes
Child themes don’t get updated for the same reason why you do not modify parent themes. The purpose of the child theme is to override and customize the parent theme, so if you updated the child theme, guess what! You lose your custom changes.
The only theme that gets updated is the parent theme, at which point the child theme will “inherit” the new update from the parent theme.
If you NEED to update the child theme, you have to do it manually and only change what is required to update. NEVER do auto updates to a child theme, or upload the complete child theme without knowing what was changed.
BACK-UPS! ALWAYS make back-ups of your theme and website.
How to Modify a Theme File
In situations where you need to modify a theme file (from the parent theme), you copy the file over to your child theme and then make your changes from there. Even if the parent theme gets updated, that file you copied won’t be affected because it exists in the child theme; only the parent theme file gets updated.
IMPORTANT: Whenever you copy a file over into your child theme, make sure that you paste it in the same location that it exists in the parent theme. For example, if the parent theme has this file:
The extras.php file would be copied and placed in the child theme in a folder named “inc“. If the folder does not exist, you will need to make it first. Once done, your child theme will have your file in a matching location as your parent:
Modifying CSS Only
If you are using a child theme and only make CSS changes, you can use the child theme’s own style.css file. No need to use the Additional CSS in the customizer or a plugin.