OFFICE

18 Bartol Street #1155
San Francisco, California 94133
United States.
Phone +1.408.878.3255

What is a Child Theme in WordPress and How It Can Be Created?

Ever since WordPress came to the market in 2003 it has been evolving continuously as per the demand and requirements in the market. No doubt it is the best CMS available to build any kind of website. When we finally decide to develop and run a WordPress Website then some of the developers ask a question – “What are the benefits of creating a WordPress child Theme for websites?”. This just shows that still so many people do not know how to create two different versions of their website. But nevertheless it is very important to create a parent and a child theme for a particular website.

It has been seen that most of the people who want a WordPress blog or site and go for WordPress Theme Development choose to use the default themes that WordPress offers but this may not be the best option all the time. Some of the best WordPress themes have minimum functionality and features and limited customization options. Actually, the best WordPress themes are those which are customizable and you may need them to build your website.

What is a Child Theme?

Child Themes are those themes which inherit and override the styles and templates of their parent themes. As in life too without parents there are no children. Similarly, in WordPress too, child themes cannot exist without parent themes. A parent theme is a theme which is created as a standalone theme. All of the single default themes which are provided by WordPress are parent themes and they do not depend on any other theme for working and functioning. On the other hand, a child theme depends completely on its parent theme. For example, if you try to activate a child theme on your website but you don’t have the parent theme then you would get an error and the theme wouldn’t be activated. This is not the same case with parent theme which can exist individually. Child theme allows you to customize a parent theme without touching the code of the parent theme. This is useful when you want to update the WordPress theme.  For example, if you have activated a theme for your website and do changes to its stylesheet or templates or JavaScript files, and then hit update when an update of the theme is available, you would lose all those customizations. But with a child theme, all of your customizations stay in the child theme, allowing you to update the parent theme and inherit those code changes smoothly.

Benefits of Creating a WordPress Child Theme

Faster Development

If you create a child theme, then it will speed up the development process of your WordPress blog or site. It is quite easy to learn as most of the WordPress themes allow setting up a theme even for beginners.

Not losing Changes

Most of the times, when you update a WordPress theme, any changes or customization which you have made to your website are lost. But if you have created a WordPress child theme then it will not happen as you can customize the child theme and then update the parent theme. In this way, all the updates and new features will automatically be applied to the child theme and its customization too will not be affected.

Can Accommodate Mistakes

When you are creating a complete theme, you also need to think about all the possible scenarios and code for them. But when you are working on a child theme and if you forget to code for something then there is always the parent’s theme’s functionality available as the working option.

Creating a WordPress Child Theme

Now you know what a Child Theme is and what are its benefits. Now let’s create one. There are few things which are required to have a child theme: –

First of all, create a new directory in your themes directory to hold the child theme. The theme directory is wp-content/themes. You should name the directory without any space and use the name of the parent theme folder with “-child” appended to it. For example, if you are making a child of the twentyeleven theme, your folder name would be twentyeleven-child.

After that, in the child theme directory, create a file called style.css. This is the only file required to make a child theme and the style sheet must start with the following lines: –

/*

Theme Name:     Twenty Eleven Child

Theme URI:      http://example.com/twenty-eleven-child/

Description:    Twenty Eleven Child Theme

Author:          James

Author URI:     http://example.com

Template:       Twenty Eleven

Version:        1.0.0

*/

@import url(“../twentyelevan/style.css”);

/* =Theme customization starts here

————————————————————– */

Now you can change the above lines to suit your theme. The only needed lines are the Theme Name and the Template. The Template is the directory name of the parent theme. In this example, the parent theme is the TwentyElevan theme, so the Template is twentyeleven which is the name of the directory where the TwentyEleven theme is placed.

The child theme’s stylesheet is included after the parent theme’s and styles will override those in the parent theme’s stylesheet.

Now activate the child theme, log into your website’s dashboard and go to the Administration Panels > Appearance > Themes. Here you will see your child theme. After that just click on the Activate button.

Conclusion

We have just discussed what is a child theme in WordPress, what are its benefits and how it can be created. No doubt creating a WordPress child theme has many benefits for your WordPress site or blog but if you don’t require too many changes to your original website then you may not need the child theme. Hence based on your custom requirements, choose the way which best suits you i.e. whether to build a child theme for your WordPress website or not. Hence do your research properly in this regard.

Make your ideas turn into reality
With our wordpress development services

Leave a Reply