How to Create a WordPress Child Theme For Customization

A child theme is a customized version of the parent theme with the same functionality, including styling. You can make changes to any element of your child theme without impacting its original parent.

When you customize a WordPress theme for your business with a Child Theme, you only need to change the code in the child theme and it will automatically update specific formatting and functionality of your website. This is an easy way to customize your website that saves time and effort.

If you like to implement the WP Adminify tweaks manually then you should create a child theme. Otherwise, your tweaks code will be removed when you update your main theme.

If you notice it’s complicated for you to create a Child Theme. Then you can easily install the WP Adminify plugin by navigating to plugins>Add new. Search for “WP Adminify” install the first one. You can access all tweaks with some extra features and no need to create a child theme.

Create a WordPress Child Theme

There are two ways for creating a child theme, First one is the manual method and the second is using a plugin. We will discuss the manual method here.

You can make a child theme by creating the folder and files that are needed. It’s helpful because you will get to know the files you need to work with later in the documentation but keep in mind it does take more time and effort than other methods.

Create Folder For Child Theme

Create a folder anywhere in your computer and give it a unique name. Make sure the name doesn’t match with any other existing theme in the WordPress repo. If your name matches any existing theme, WordPress will notify you to update your child theme when that theme releases an update. If you accidentally update, then you will lose your child theme data.

Creating Style.css for your Child Theme

Create any text document and rename it style.css. Make sure to use .css as file extension. Then copy the following code and paste it inside your style.css file.

				
					/*
 Theme Name:  WP Adminify Child
 Theme URI:   https://wpadminify.com/
 Description: My Child Theme for customization. 
 Author:      WP Adminify
 Author URI:  https://wpadminify.com/
 Template:    your active theme slug
 Version:     1.0.0
 License:     GNU General Public License v2 or later
 License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
				
			

You are free to change the Theme mane, URI, Description, Author, etc info on your needs. But make sure to use the active theme slag. as Template. Otherwise, it will not work. You can also write any custom CSS code inside this file.

Creating function.php File

Follow the same method as style.css. After creating a text file, name it function.php. Here you have to enqueue scripts and style from the parent theme. You can take a look at the WordPress Theme handbook for a better explanation. Here is a code that works for Twenty Twenty-One Theme.

Find out your theme CSS ID. Visit your website homepage and open the page source [click CTRL+U, or CMD+U]. You will get the Theme style CSS ID inside your head area. Just search with your theme name and it will be looks like the following line. Here “active-theme-style” is the id. Apply the same way to find our your theme script id. 

				
					<link rel='stylesheet' id='active-theme-style-css' href='https://domain.com/wp-content/themes/your-theme/assets/css/active-theme.css?ver=5.8.1' type='text/css' media='all' />
				
			

Change the following “active-theme-style” Id with your theme style and script id. 

				
					function wp_adminify_child_scripts() {
	
	// enqueue style
	wp_enqueue_style('active-theme-style', get_stylesheet_uri());
	
	// enqueue script
	wp_enqueue_script('active-theme-script', get_template_directory_uri() .'/js/functions.js', array('jquery'), '20150825', true);
	
}
add_action('wp_enqueue_scripts', 'wp_adminify_child_scripts');
				
			

Adding Theme screenshot image

This step is not required, but if you like to preview a Theme image then you should add an image and name it screenshot.png. WordPress will automatically detect this screenshot as your theme preview image.

That’s all about creating a WordPress child theme manually. If you still have any question feel free to contact us and we will assist you.

September 12, 2021
Getting Started
Was this article helpful?

© 2021-2024 - Adminify | All rights reserved

WP Adminfy accepted payment methods