How to create a child theme in WordPress?

/
/
/
790 Views

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
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.

Leave a Comment

Your email address will not be published. Required fields are marked *

This div height required for enabling the sticky sidebar