Hello! Creating a child theme in WordPress allows you to make changes to an existing theme without modifying its core files. Here’s a step-by-step guide on how to create a child theme:
Create a new folder on your computer or in your host server. Give it a name that represents your child theme (e.g., my-child-theme
).
Inside the newly created folder, create a new file called style.css
. Open it in a text editor.
In the style.css
file, add the following code to define the information about your child theme:
/*
Theme Name: My Beautiful Child Theme
Template: twentytwentytwo
*/
Replace My Beautiful Child Theme
with the desired name for your child theme, and twentytwentytwo
with the name of the parent theme you want to create a child theme for.
Save your style.css
If you want to override specific template files from the parent theme, create a new folder within your child theme folder called template-parts
. You can replicate the directory structure and file names of the templates you want to override. For example, if you want to override the content.php
file, create the following structure: my-child-theme/template-parts/content.php
.
Next, upload the entire child theme folder (including the style.css
file and the template-parts
folder if applicable) to the wp-content/themes/
directory on your WordPress site.
Log in to your WordPress admin area and go to Appearance > Themes. You should see your new child theme in the list. Now, select “Activate” button to activate your child theme.
Always refer to the official WordPress documentation for best practices.
Contact me with any questions. Also, check out my IT Handyman shop. I make my own coffee mugs and T-Shirt designs. Thanks!