Most bloggers and developers use child themes to speed up their website building work. So that they can easily modify and customize their website in any way they want.
By using a child theme, they can create their desired website very quickly. Child themes give them more flexibility to insert their code and functions without touching the parent theme file.
In this article, I will show you how to create a WordPress child theme in easy steps.
I’m sure you have read my previous article, What is a WordPress Child Theme? If you haven’t read it, please go and read it before creating a WordPress child theme.
I hope now you have read my previous article, so let’s start the step that how to create a WordPress child theme –
Creating a Child Theme in WordPress
The following instructions use GeneratePress as a base, and you can use any other WordPress theme if you want. I’m going to use GreenGeeks Hosting File Manager to add and edit files. However, FTP also works.
Now, without any hassles, here is how to create a child theme in WordPress –
Step 1 – Open the Theme Directory
- Login to your GreenGeeks Hosting account.
- Access your cPanel and click on File Manager.
- Now navigate to the public_html – wp-content – themes folder.
- Finally, click on the + Folder option from the top left side toolbar.
Step 2 – Create a New Folder for the Child Theme
- Then create a new folder by clicking on its icon. Enter the name of the child theme and click Create New Folder.
It is recommended to use the parent theme’s name followed by a -child suffix. In this example, I have named the folder generatepress-child.
Please note that replace spaces in a folder or file name with a hyphen (-) to prevent errors.
Step 3 – Create style.css File
- Go into the folder that you created, now click on the + File option from the top left side toolbar.
- Name the file style.css and click Create New File.
Now, populate its content with the following code –
/*
Theme Name: WPSettingbox
Theme URI: http://wpsettingbox.com
Description: WPSettingbox Blog Theme is a Child Theme Built on GeneratePress.
Author: Dipak Singh
Author URI: https://www.imjustdipak.in
Template: generatepress-child
Version: 0.1
*/
You can change all the values as you like, but here is the most important area Template. Because it tells WordPress which parent theme your child theme is based on.
- Once all is done, now don’t forget to click on the Save Changes button on the file.
Step 4 – Create functions.php File
Finally, create another file and name it functions.php in the same folder.
- Now copy the following code and paste it into the blank file.
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>
- Now click on the Save Changes button on the file.
Step 5 – Activate the Child Theme
Once you have done the style.css and functions.php files of the child theme folder now you need to activate it in the WordPress dashboard.
- Go to your WordPress Admin dashboard and go to Appearance – Themes.
- Activate the child theme you just created, and you will see that it looks exactly like the parent theme.
Now your child theme is ready for modifications, customizations, and adding your code without touching the parent theme file.
In my case, I have already activated my child theme.
I hope this article will help you to create your WordPress child theme. This will give you a speed for your website development work.
If you face any troubleshooting for creating your WordPress child theme, so feel free to ask me for the most appropriate solution.
I will be glad to help you.
If you liked this article, please show your love by sharing it on your favorite social media channel and also send your thoughts in the comment section.
(Get fresh and updated content from WPSettingbox on Facebook, and Twitter.)
I love your comments. It makes me more precise to give you the best WordPress resources and guides.