The Importance of Using a WordPress Child Theme
What is a child theme?
A WordPress child theme acts as an intermediary between the parent theme and the design and layout of the website. If a file exists in the child theme which the parent theme attempts to load, the child theme’s version of said file will be loaded in its place.
In contrast to a child theme, the parent theme is the primary theme which contains the necessary files for the theme to function. A child theme will not function properly without an associated parent theme. In some instances a parent theme has not been developed using functions which are intended to load child-theme files in lieu of their parent theme counterparts. In this instance the functionality of the theme will need to be modified in order to load the child theme’s files.
Why do I need a child theme?
Child themes allow you or your team to make modifications to the theme’s appearance and functionality while maintaining the ability to apply updates to the parent theme’s files without overwriting, also known as clobbering, the customizations which have been made. Without the customizations being made to a child theme’s files you risk reverting or breaking your website once a new update is applied for your parent theme.
Example Using a Child Theme:
Request: You’ve asked your WordPress developer to make the necessary modifications to your website’s header in order to create extra space for your navigation menu to display so that additional links can be added.
Result: To make these changes, your WordPress developer will need to modify the code structure of the existing header.php template file. Your WordPress developer, aware that the modifications must be made to the child theme, makes the necessary changes to the header.php file and installs the edited copy of that file into the child theme. Now, when your website is loaded the header.php file in the child theme, with the customizations, is loaded in place of the default header.php file which resides in the parent theme. This leaves your parent theme free to have updates applied without concern for overwriting the customizations.
Example Without Child Theme:
Request: You’ve asked your developer to make the necessary modifications to your website’s header in order to create extra space for your navigation menu to display so that additional links can be added.
Result: To make these changes, your developer will need to modify the code structure of the existing header.php template file. Without knowing the benefits of a child theme, your developer makes the necessary changes to the header.php file and uploads them directly to the parent theme, overwriting the default header.php file. Now, when your website is loaded the customized header.php file in the parent theme is loaded and everything functions as intended.
At a later date, without knowing the consequences, your developer installs a parent theme update to your website. In this process, the header.php file is overwritten with the parent theme updates, removing the customizations. Your developer will now need to reimplement the customizations to the new header.php file, creating additional work and expense. This also assumes the developer notices the issue immediately, otherwise it would be left with the customization being reverted until the issue is noticed and communicated to the developer.
Simply put, the child theme allows us to override the parent theme’s files allowing the parent theme to be updated without fear of the customizations being overwritten.
What if I don’t have a child theme and my parent theme was altered?
That’s where we come in!
If your WordPress website is using a parent theme which has been customized, applying a parent theme update will overwrite those customizations and cause the appearance and layout of your website to change. To remedy this we review your parent theme’s customizations by comparing it to the updated parent theme’s files, making note of everything that needs to be ported into a child theme. We then:
- create a development environment
- install the updated version of your parent theme
- create and install a child theme which works with your parent theme
- transfer settings from the old parent theme into the new parent theme
- transfer code customizations from the old parent theme into the child theme
- work with our client to review the updates and any changes which were required based on new / updated coding standards
- with client approval, roll out the updates and modifications to the production website
We haven’t updated our parent theme in a while and now we’re seeing coding errors and issues which mean we have to update the parent theme, but doing so causes other problems. What do we do?
This is an unfortunate circumstance which crops up quite often. The only way to remedy these issues is to dive in and begin porting the customizations over to a child theme, thus freeing the parent theme to have updates applied. There is really no way around this, either the customizations are made through a child theme ahead of time, or that process needs to take place once the issue is identified.
But what if my parent theme has been updated and that’s when we noticed the issues with not having a child theme?
We’ll need to attempt to recover your old, customized parent theme from a backup in order to begin the process of porting those changes over to a child theme. We may also be able to temporarily install the old parent theme in order to restore functionality to your production website while we complete the creation of the child theme in a development environment.
Do you have customizations which need to be preserved through the process of updating a parent theme by moving them to a child theme? For help with this, or anything else WordPress, Bellingham WP is here to help!