A child theme is a theme which inherits the functionality and styling of another theme, called the parent theme. These themes are the recommended way of modifying an existing theme.
In this short article, I’m going to tell you in brief how child themes work in WordPress.
The first step in creating a child theme is to create the child theme directory, that will be placed in wp-content/themes. The name of your child theme directory is appended with ‘-child’. You will also should to make sure that there are no spaces in your child theme directory name, which may result in errors. So here’s a step by step list of the things you should do to make them work.
So, let’s get started!
- You make the child theme: just one directory and one CSS file in it.
- You may also use a functions.php file.
- The child theme, in its CSS file, declares its parent, i.e., the theme whose templates it uses. It inherits all files of the parent except the stylesheet. Once everything is in place, the child theme:
- Is activated like any other theme, via the administration panel.
- Behaves exactly like its parent, in everything. For example, if the parent has an options page, the child will have it too.
- Looks exactly like its parent, plus or minus any changes you make: you can modify everything beyond recognition or just change one tiny, unnoticeable detail.
- You don’t have to keep track of your modifications or worry about losing them the next time the parent theme is updated, since you haven’t touched the parent theme. Your changes live in their own file(s) within their own directory in wp-content/themes.
This much, guys! Hope this article gave you the info you needed.