TUTORIAL: How to create a child theme in WordPress

Tags: , , , , , , , , , .

Posted 4 years ago


TUTORIAL: How to create a child theme in WordPressIf you’re a WordPress user, and are thinking of customizing the theme of your website, then the child theme is an option that can be chosen. The child theme is of immense importance. Some of the benefits of using the child theme include the ones like making changes without affecting the original theme’s code. This results in an easy update of the parent theme of the website without any need to erase the changes. There will be no modification to the original theme while customizing the child theme. For this, the user can create separate files for the theme customization, and the child theme lets him do so. Thus, the original theme is not affected at all, and when needed, the user can turn off the child theme anytime and switch back to using the original theme.

The tutorial to create a child theme is as follows:

To create a child theme for the Foxy theme, follow the following steps:

  • Create a new folder
  • Name it something like /foxy-child/
  • Create a file called style.css within the new theme folder
  • Fill the following information in the style.css – theme Name, URL, Description and Author

This file will contain “Template:” and @import sections and these are one of the vital elements of the file. It is these sections which identifies the process of the parent theme importing the CSS from the original. At this point, the user will have to check that the path to the parent theme’s CSS file is correct and the “Template:” parameter must also be able to correctly identify the name of the parent theme.

The next step will be activating the child theme, and this is just the same process as activating a normal theme. To do this, the user will have to upload it via the Appearances > Themes page in their WordPress Dashboard, and activate it. But before uploading the theme, one should ZIP it first. Along with the upload of the child theme, the parent theme should also be uploaded.

This will be followed by modifying the Theme’s CSS, and it’s necessary, as until now, only the original theme’s CSS has been imported — the new child theme will look exactly like the original. So, to give it a new look, the user can add changes to the child theme’s CSS file below the @import line.

In case you need to add more custom functions to the child theme, you can do so by editing the Functions.php file. There should be a php opening tag in the beginning of the child theme’s functions.php file a php closing tag in the end. The desired php code can be placed in between.

There are some other ways to get started with a child theme, and additional child theme resources are:

The One Click Child Theme Plugin (Please note that this plugin has not been updated in some time) – with the help of this plugin, you can create a child theme with the click of a button without any need to go through the lengthy procedures explained above.

The WordPress Codex – for finding answers about child themes, or for anything related to WordPress development, check out the the WordPress Codex.

– Ady Sachdeva


Leave a Reply