Do you wish to customize some WordPress theme features without risking irreversible modifications? Creating a WordPress child theme can help you do just that. Child themes are a great way to preserve whatever changes you make to your website without having to worry about losing changes on the next theme update. In this guide, we will walk you through the process of creating a new child theme and outline two ways to do so.
What are WordPress Child Themes, and Why Are They Useful?
A child theme is a theme that inherits another theme’s style, features, and functionalities. The theme the child theme inherits properties from is called a parent theme.
The creation of a child theme is a time-efficient and convenient way to customize a WordPress theme. Instead of coding the entire theme from the ground up, creating child themes allows you to use the style and functionalities of a theme you like, and only make changes necessary for your goals.
As the parent theme already includes most of the functionalities and formatting you need, you will save time on coding and only need to make small changes in code.
Apart from that, installing a child theme allows you to experiment safely with changes to your parent theme. It will enable you to change the code of your theme without modifying the parent theme itself.
When you are satisfied with your child’s theme, you can use it to create a new WordPress website, as you would with the parent theme.
Skills Needed to Make WordPress Child Theme
Initially, you should choose a theme that aligns with your goals and preferences. That theme will be the parent theme that you will be modifying.
Creating and modifying a WordPress child theme, however, requires at least some coding knowledge. Modifying the WordPress theme can be a valuable learning tool. On the other hand, you should avoid customizing your WordPress code for business purposes and rely on professional WordPress development services.
When creating a child theme, you will need to change the code, making basic knowledge of HTML and CSS a requirement. Luckily, there are many online resources to familiarize yourself with HTML and CSS basics, of which we recommend W3Scholls HTML and CSS tutorials.
Furthermore, some knowledge of PHP would be highly beneficial if you need to modify theme functionalities. It would help if you had a basic understanding of PHP syntax to use code snippets effectively.
The Two Ways of Creating WordPress Child Themes:
There are two ways to create a WordPress child theme. You can manually create a necessary folder and files or use a plugin to create a child theme.
Way 1. Using code
You can code almost anything in WordPress. Whether it is a simple plugin or an advanced theme, in this case, a child theme. This method is the best if you want complete control over your child theme and its code. follow these steps to create a child theme in WordPress using code:
Step 1. Create a folder
You should create a new folder in the themes folder in your WordPress installation folder (/wp-content/themes/).
Step 2. Create files
Create two empty text files in the folder created in the previous step.
Name the first file style.css, open it in a text editor (Notepad, Notepad++, or VS Code), and paste the following code:
Theme Name: Your Child Theme Name
Theme URI: Your URL
Description: Your Child Theme Description
Author: Name
Author URI: Your Author URI
Template: Parent theme name
Version: Version number
Text Domain: Parent theme text domain
Modify the code to align with the code after “:” to align with your parent theme and domain information. Keep in mind that, failure to add a style.css file will result in the “The package could not be installed. The theme is missing the style.css stylesheet” error.
Name the second file functions.php, and paste the following code:
/* enqueue script for parent theme stylesheeet */
function childtheme_parent_styles() {
// enqueue style
wp_enqueue_style( 'parent', get_template_directory_uri().'/style.css' );
}
add_action( 'wp_enqueue_scripts', 'childtheme_parent_styles');
Modify the red-colored parts of the code in accordance with your chosen parent theme.
This file will import stylesheets from the parent theme.
If you have trouble creating a child theme manually, you can use the Child Theme Configurator plugin.
Way 2: Using Plugin
Using the Child Theme Configurator plugin enables you to create a child theme without manually creating all the files.
If you decide to use it, create a child theme following the steps:
Step 1. Install the Plugin
Install the Child Theme Configurator and activate it. For installation of WordPress plugins, refer to this guide.
Step 2. Choose a parent theme
Go to tools> child theme in your WordPress dashboard. Choose your parent theme in the Parent/Child tab and click Analyze. Once the analysis is complete, the plugin will inform you if the theme is suitable for a parent theme.
Step 3. Set folder and files
After the analysis, you will be prompted to configure the folder name and choose how stylesheets will be accessed. If you are new to creating WordPress child themes, we recommend using the default option.
Step 4. Copy the menus
Check the box next to “Copy Menus, Widgets, and Other Customizer Settings from the Parent Theme to the Child Theme.“
This will allow your child theme to inherit menus, widgets, and other settings from the parent theme.
Step 5. Create Child Theme
Click on “Create New Child Theme.” The plugin will create your child theme folder and style.css and functions.php files that you will use for customization.
Step 6. Preview the child theme
You will be prompted to preview the child theme. Click on the “Preview your child theme” link at the top of the screen. Ensure that the preview version of your WordPress child theme works and looks good.
Step 7. Publish the theme
If the preview works well, you can publish your child’s theme on your website. Do so by clicking the “Activate & Publish” button. Your child theme will go live on your website when you click it.
Customizing Your WordPress Child Theme
Now that your WordPress child theme is created, you can start customizing it without risking the changes of the parent theme.
Modifying style
To customize your child theme’s style, go to your WordPress installation directory, open the themes subfolder, and access the folder with your child theme’s name. Open style.css with a text editor, and modify CSS components by writing your new CSS code under the heading.
Adding functionalities
To customize your child theme’s style, go to your WordPress installation directory, open the themes subfolder, and access the folder with your child theme’s name. Open style.css with a text editor, and modify CSS components by writing your new CSS code under the heading.
To customize your child theme’s functionalities, open the functions.php file inside your themes subfolder in your WordPress installation folder (/wp-content/themes/). If you are unfamiliar with PHP programming, you can view your functions.php files as WordPress plugins. In this file, you can paste already-written PHP code to add functionalities to your child theme. That, however, is only recommended for learning purposes.
Conclusions
Creating a WordPress child theme is a convenient way to start developing a theme on the foundation of a theme you already like or use. By creating a child theme, you can save time on coding and experimenting with modifications without changing your parent theme.
However, creating a compelling WordPress theme requires CSS, HTML, and PHP coding knowledge. As such, you should avoid changing the code for business purposes if you are not proficient in WordPress development.
On the other hand, it is a valuable learning tool that can enable you to practice PHP and CSS coding.