How To Create WordPress Child Theme
Why Create Child Theme
Oftentimes, we need to customize bought theme to suit with our requirements. But with doing so, we won’t be able to update the theme to it’s latest version or else the changes we made will be overwritten.
The avoid this, instead of doing the changes to the theme, we will need to create a child theme. On the child theme, we can do any changes we desired. Changes does not limit to customizing the layout, but also to creating many complex functionality such as adding options page, custom meta types, etc.
- Install the parent theme to your wordpress site
- Go to the wp-content/themes folder
- Create the a new folder, and name it as you want
- Under the newly created folder, create the ff. file
Open style.css and add the ff.[code]
Theme Name: Foxy Child Theme
/* =Theme customization starts here——————————————————- */[/code]
replace the red text with the correct data
- Open wordpress dashboard, then go to appearance ? themes.
- You can see your child and you can activate it.
- Since no customizations were done yet, your site will look exactly as if the parent theme is the active theme.
You can add any css modifications into the style.css
If you want additional functionality to your child theme, such as custom post meta types, new settings page, you can do so by creating functions.php at the root of your child theme’s folder
Any codes on this file should be wrap with php tag, though end tag is optional.
// Your php code goes here
?> <!– optional ?
Note: The parents functions.php will be loaded first before the child themes’ function that php
If you want to customize other files, such as header.php, footer.php, etc, you can do so.
First copy desired file name the parent theme to your child theme’s folder. You should follow the extract directly tree. So if the file is in the root of parent theme, the file should be copied to the root of the child theme. Edit the copied file as desired.
Note: Except style.css and functions.php of the parent theme, all other files that has counterpart on the child theme’s folder will never be executed.