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

Top 5 Android Phones in India (2024): OnePlus Open, Samsung Galaxy S24 Ultra & More

Top 5 Android Phones in India Top 5 Android Phones in India for 2024: Unmatched…

3 months ago

Chapter 3: Understanding HTML Headings and Paragraphs

https://www.youtube.com/watch?v=QU0Hm7k_hWI Introduction: Previously, in Chapter 2, we discussed html elements and structure. In this chapter,…

4 months ago

Chapter 2: HTML Elements and Structure

https://youtu.be/HihwZMLuXGY Introduction: Welcome back to our HTML course! In the last chapter, we explored the…

4 months ago

Mastering Laravel Eloquent ORM: Easy Guide for Beginners

Introduction Mastering Laravel Eloquent ORM: Easy Guide for Beginners Laravel, one of the most popular…

4 months ago

Chapter 1: Introduction to HTML Basics

https://youtu.be/nPljiJtfBUQ In this chapter We will understand What HTML Is Understanding What HTML Is: Introduction:…

12 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…

2 years ago

This website uses cookies.