Categories: Wordpress

How to create a child theme in WordPress?

If you are looking for how to create a child theme in WordPress then this article is for you.

In this article of 91 TechSquare, We will provide solutions to create a child theme in WordPress. There are many ways to create a child theme in WordPress which are following:

create a child theme in wordpress

1. Create a child theme by style.css file:

  • Create a directory inside wp-content/themes/your-child-theme-directory

You can choose any name of your directory to create a child theme.

  • Create a style.css file inside your child theme directory

Remember, the file name should be style.css inside your child theme directory as wp-content/themes/your-child-theme-directory/style.css. Then put the below code inside your style.css file.

/*
 Theme Name:   91 TechSquare Child Theme
 Theme URI:    https://www.91techsquare.com/
 Description:  A Twenty Thirteen child theme 
 Author:       91TechSquare
 Author URI:   https://www.91techsquare.com
 Template:     twentythirteen
 Version:      1.0.0
*/ 
@import url("../twentythirteen/style.css");

That’s it. You just need to remember that Template: should be your main theme name and what in line 11 twentythirteen should also be replaced with your main theme directory name.

If you do not want the whole stuff inside style.css, you can also use only the below code.

/*
 Theme Name:   91 TechSquare Child Theme
 Template:     twentythirteen
*/ 
@import url("../twentythirteen/style.css");

Both the code will work with efficiency. Congrats, now you know how to create a child theme in WordPress. You just need to go inside the appearance/theme in the WordPress admin panel. Then activate your child theme.

2. Create a child theme by style.css and functions.php file:

There is another way to create a child theme in WordPress. Now you need to create two files inside wp-content/themes/your-child-theme-directory. The first one is style.css and another is functions.php

  • wp-content/themes/your-child-theme-directory/style.css
  • wp-content/themes/your-child-theme-directory/functions.php

Put the below code inside the style.css file to tell WordPress which template is to be used.

/*
 Theme Name:   91 TechSquare Child Theme
 Theme URI:    https://www.91techsquare.com/
 Description:  A Twenty Thirteen child theme 
 Author:       91TechSquare
 Author URI:   https://www.91techsquare.com
 Template:     twentythirteen
 Version:      1.0.0
*/

Or, you can also use the below code in the style.css file

/*
 Theme Name:   91 TechSquare Child Theme
 Template:     twentythirteen
*/

Put the below code inside the functions.php file to link enque styles of parent theme to child theme.

<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
   wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>

The child theme is created. You just need to go inside the appearance/theme in the WordPress admin panel. Then activate your child theme.

3. Create a child theme by using the plugin:

You can also create a child theme by using the plugin. There are lots of plugins to create a child. Some of the plugins are following as:

Congrats, now you know how to create a child theme. You just need to go inside the appearance/theme in the WordPress admin panel. Then activate your child theme.

91 TechSquare

Recent Posts

Chapter 1: Introduction to HTML Basics

In this chapter We will understand What HTML Is Understanding What HTML Is: Introduction: In…

4 months ago

The SOLID principles: how to use them in Laravel to write better code

The SOLID principles are a set of guidelines for writing clean and maintainable code that…

1 year ago

How to add a custom admin menu in WordPress dashboard?

In this article, We will learn to create a custom admin menu in the WordPress…

2 years ago

How to use ajax in WordPress?

In this article, you will learn how to use Ajax in WordPress. Ajax has rapidly…

3 years ago

How to create a custom dynamic WordPress widget?

In this article, you will learn how to create a custom dynamic WordPress widget. I…

3 years ago

How to create a custom widget in WordPress?

When you work with WordPress, you might have a question that how the widget in…

3 years ago

This website uses cookies.