In this tutorial, you will learn how to create a child theme in WordPress. We have given two methods; one is manual and the other is via a Plugin.
Why do you need a Child Theme?
If you want to customize the styles and functions of your theme, then you need a child theme. You can also make these changes in the parent theme without having a child theme provided that these changes are minor and in styles only. If your theme does not get regular automatic updates, then you don’t need a child theme. If your theme updates regularly, then you consider creating a child theme. Any changes made in functions like functions.php or header.php etc. vanish with the theme update.
You can make a child theme either manually or by using a plugin.
Create a child theme with a Plugin
Plugins are a great choice when you are not satisfied with your coding skills. Plugins provide a user-friendly interface to make changes in the functionality or appearance of your WordPress site. To create a child theme, a plugin named Child Theme Configurator is the first choice. It has 300,000 plus active installations and a five-star rating of 212. To install this plugin, head to Plugins>Add New. Type “Child Theme Configurator” in the search, and this Plugin will be the first one to appear. Click on Install and then activate.
When you activate the Plugin, go to tools and click on Child Theme Configurator. Set the following Plugin options, and you are done.
Child Theme Configurator Options
Step 1: Select an action: Create a new Child Theme
This has only one option and it is set by default i.e. “Create a new Child Theme”.
Step 2: Select a Parent Theme
Here you will have to select the theme for which you want to create the child theme. If you have installed more than one theme, all of them will be listed here.
Step 3: Analyze the parent theme
Select the target theme and click on “Analyze”. The Child Theme Configurator will check compatibility issues and generate a report.
You will get the following messages if the child theme can be created.
This theme appears OK to use as a Chile theme.
This theme loads additional style sheets after the style.css file; in case you have used additional CSS.
Step 4: Name the new theme directory
Give a suitable name for your child theme directory (folder). All your child theme files will be stored within this folder.
Step 5: Select where to save new styles
You will have to select one of the options here. We recommend selecting the option “Primary Stylesheet(style.css)
Step 6: Select parent theme stylesheet handling
You will find multiple options in this option like (1) use the WordPress style queue (2) use @import in the child theme stylesheet (3) Do not add any parent stylesheet handling (4) ignore parent theme stylesheets. We recommend using the first option and using the WordPress style queue method.
Step 7: Customize the child theme name, description, and author
Here, you set the options like giving a name to your child theme, theme website, author, author website, theme description, theme tags, and version. We recommend leaving all these fields to the defaults as filled by the Plugin.
Step 8: Copy Menus, Widgets, and other customizer settings
Tick this option if you want to use the menus, widgets, and other settings of the parent theme in the child theme.
Step 9: Click to run the Configurator
Click on “Create New Child Theme” and your child theme is now ready to activate. Activate the child theme and browse your site to see any style differences.
Note: if you had used custom CSS in the parent theme, cut and paste the theme in the style.css of the child.
Create a Child Theme in WordPress without Plugin
This is a scalable option included by the developers of WordPress to style any theme according to customer needs and flavors. With the help of a child theme, one can modify the parent theme without actually changing the codes in the original theme. This is very useful as the changes will not vanish after the theme updates.
There are many changes one does in the functions, style, and header file of the theme and those changes disappear after updating the theme. So this child theme allows changing the master theme as much as you want without affecting the parent theme.
Must have functions in Child Theme
To create a child theme in WordPress, you must have style.css and functions.php files. You can also include other files optionally. Using these PHP and CSS files we can change the factions and layout of the main theme. When the site is loaded, the styles of the child theme are loaded first, and then missing styles are loaded from the main theme.
Follow the following steps to create a child theme without using a plugin.
- Login to your Cpanel
- Browse public html/wp-content/themes
- Click on New Folder and Give a suitable name to your child theme. It is recommended to add the child after the theme name so that it can be distinguished.
- Browse the newly created theme
- Add a file by the name style.css
- Insert the following lines of code in styles.css
Theme Name: Give suitable name here
Theme URL: Give URL of your site
Description: Provide suitable description about child theme
Template: This is must and must be the name of parent theme without spaces
Text Domain: name of child without spaces
Have a look at the following figures.
- Add another file by the name of functions.php and insert the following code in it
Add_action( ‘wp_enqueue_scripts’, ‘enqueue_parent_styles’);
Function enqueue_parent_styles(‘parent_style’, get_template_directory_url().’/stle.css’);
This was a complete Process of How to create a child theme in WordPress without using plugins.