What is Child Theme in WordPress?
A WordPress Child Theme is a theme that inherits the functionality and styling of another theme, called the Parent Theme. Child Themes allow you to modify, or add to the functionality of your site, by letting you reuse the code from an existing theme.
Any change made to parent or child theme will not affect the other, which makes it possible to update the Parent Theme without affecting your modifications.
You can also update your Child Theme without affecting the original Parent Theme. This tutorial will show you how to use Child Themes in WordPress.
Creating New Child Theme in WordPress
To create a child theme in WordPress, you must first choose and set up your Parent Theme. You can either use an existing WordPress theme or start with a blank theme.
If you are using an existing WordPress theme, you can create a child theme by copying the parent’s folder and then renaming it.
If you are starting with a blank theme, you can create a new folder and name it whatever you want. In this example, we will use the ” Twenty Fifteen ” theme as our Parent Theme.
Create a new folder inside your themes directory and name it ” twentyfifteen-child “.
Rename functions.php inside the parent theme (Twenty Fifteen) folder to functions-parent.php . Open functions-parent.php file in any text editor and copy all the code into your new functions.php file.
Now, open style.css located inside parent theme (Twenty Fifteen) folder and copy all the code into your new style.css file.
Finally, open an empty page on your site and click on ” Editor ” located under appearance menu. Click the ” Setup Child Theme ” button and then click on ” Create a Configuration File “. Insert your site Title and Tagline (if any) inside Site Title & Tagline fields. Finally, click on ” Let’s Go! “.
Your child theme is now created and you can start making changes to it.
Editing Child Theme in WordPress
Now that you have created a child theme, you can start editing it. The easiest way to do this is by using the WordPress Theme Customizer.
The WordPress Theme Customizer lets you make changes to your site’s design via a live preview.
To make any change, click on Customize button located under the appearance menu. If you don’t see the Customize button, make sure you are on your site’s front end and logged in as administrator.
Once the WordPress Theme Customizer is opened, click on the ” Site Title & Tagline ” section and change your site title. Click on Save & Publish button located at the top-right corner of the Theme Customizer.
You can also make changes to your child theme’s style.css file. However, before editing your child theme’s style.css file, you must first overwrite its original content with the code from your parent theme (Twenty Fifteen).
Once you have copied the original content of style.css file, you can open it in your text editor and make modifications to it.
The changes you make to your child theme’s style.css file will only affect the front-end of your website. It won’t affect the back-end, which makes it easier for you make changes to the design of your site.
Using Child Theme in WordPress
You can activate your new child theme in three ways.
Activating Child Theme Manually
To activate your child theme manually, you must first deactivate all other installed themes.
To do this, click on Appearance menu located under your WordPress dashboard’s left-hand menu and choose ” Themes “. Find all the themes you have installed and click on ” Activate ” button next to your new child theme.
Activating Child Theme Automatically
You can also automatically activate your child theme when you activate your Parent Theme.
To do this, go to ” Functions.php ” file inside the parent theme folder and add this code:
add_theme_ activation ( ‘ twentyfifteen-child’ );
Finally, save and close the file.
Creating a Child Theme in wordpress via Plugin
If you don’t want to manually create a child theme for your WordPress website you need house the Child Theme Configurator plugin
To do this, install and activate the ” Child Theme Configurator ” plugin. Once the plugin is activated, you can make changes to your child theme and see the results in real-time.
When Not To Use a WordPress Child Theme
There are a few cases when you might not want to use a WordPress child theme.
-If you are just making minor changes to your site’s appearance, you might not need to create a child theme.
-If your website is using custom coded plugins or functions that are not available in WordPress theme directory, creating a child theme might not be necessary.
-If you want to create custom post types or modify the way your website works, creating a child theme is not the best solution. In this case, you should create a plugin instead.
Creating and using a WordPress child theme is a great way to make changes to your site’s design without affecting the code of your parent theme.
It’s easy to create a child theme and it’s a great way to learn more about WordPress.
In this article, we have covered the basics of creating and using a WordPress child theme. We have also looked at some of the cases when you might not want to use a child theme.