All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

How To Create Child Theme In WordPress

Last Updated : Mar 11, 2024

How To Create Child Theme In WordPress

In this article we will show you the solution of how to create child theme in WordPress, making changes to the code of your WordPress theme is safe when using a child theme.

Use a WP child theme without a doubt if you wish to directly alter the CSS, HTML, or PHP of your theme.

Should users upgrade your theme again, your changes might be lost.

The look, feel, and features of a parent theme are inherited by a child theme, which is a subtheme.

It is installed similarly to every other theme, but its functionality is controlled by the parent theme.

The child theme's files are kept apart from those of the parent theme when you modify them.

Additionally, modifications you make to a child theme would then supersede changes visitors make to the parent theme's behavior.

The parent theme can be changed without affecting your customizations if a child theme is created.

Step By Step Guide On How To Create Child Theme In WordPress :-

//Style.css
//For All the Theme Styling

/*
Theme Name: astra-child
Theme URI: http://localhost/demo/
Description: Astra Child Theme
Author: TalkersCode
Author URI: http://localhost/demo/
Template: astra
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: two-column, responsive-layout
Tags: two-column, responsive-layout
*/

//Functions.php
//PHP function will be implement here

<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>
  1. First, make a folder in which to store all of your child theme's template files and assets.How To Create Child Theme In WordPress
  2. You can create this document on your local computer for the time being.You'll discover how to upload the child theme to your website later on in this tutorial by placing the files in a Zip folder and doing so through your WordPress dashboard.
  3. Use the parent theme's folder name and append "-child" at the end.So, if you were making a Astra child theme, you would name the folder "astra-child."
  4. Then, inside your child theme folder, create the "style.css" file, that will contain all of your child theme's CSS rules and declarations.How To Create Child Theme In WordPress
  5. Create the file using your preferred text editor for coding or any simple text editor, like Notepad (e.g., Sublime Text).
  6. The most crucial thing to remember is that in order for stylesheet to function, a requisite header comment must be added at the top of the file.
  7. When you modify their child theme further, such as by adding custom CSS, certain parent theme styles and functions, such as functions.php, will be supplemented or replaced.How To Create Child Theme In WordPressHow To Create Child Theme In WordPress
  8. The two required files, "style.css" and "functions.php," have been created, and you now have to go to wordpress dashboard>Appearance> theme details> then right click and save parent theme image in the astra-child folder and you need to create a simple child theme.How To Create Child Theme In WordPress
  9. The child theme folder needs to be compressed as a Zip file in order to be packaged into a file that can be installed through your WordPress dashboard.How To Create Child Theme In WordPress
  10. As with any other WordPress theme, you can now install this Zip file.
  11. Just go to your WordPress dashboard but also select Appearance >Themes > Upload Theme to upload the file. Then, using the file picker, can choose the Zip file visitors just created and press the Install Now button.How To Create Child Theme In WordPressHow To Create Child Theme In WordPress
  12. Once it has been uploaded, WordPress should notify you that a parent theme is necessary and that it has been installed.How To Create Child Theme In WordPress
  13. If everything appears to be in order, press the Activate button.
  14. Their child theme has now become available! When you start a theme in your dashboard, visitors should find the correct details.

Conclusion :-

WordPress only needs a few steps to create a child theme. We'll go above each one in detail below to enable you to follow along.

The Twenty Twenty-One default theme for WordPress will be used as an example in this demo, but the fundamental procedures are the same for all WordPress themes.

I hope this article on how to create child theme in WordPress helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Anjali

Experienced Computer Programmer with a broad range of experience in technology. Strengths in application development and Object Oriented architecture design, front end programming, usability and multimedia technology. Expert in coding languages such as C, C++ Java, JavaScript, PHP and more.

Follow Anjali On Linkedin 🡪