Use a Child Theme when modifying your theme files

June 15, 2014| Sushil Adhikari

You will hear this often and this is something that WordPress recommends; but if you plan to make custom changes to your theme, whether mine or from someone else, the best way is to use a child theme. You can read more about child themes here:

Child Themes

The reason for using a child theme is because when updates are available for your theme, in this case the parent theme of Preferential, you won’t lose any custom changes because they were done in the child theme. How this works is that the child theme inherits the styles and functionality of the main theme (the Parent theme), so any updates that happen, it will inherit those. However, if you made any custom changes to the theme, these exist in the child theme and not the parent theme, which is why when you update, you don’t lose the changes.

When to Use a Child Theme

Easy guideline for you:

  • If you plan to make custom changes to any theme files, either now or in the future, use a child theme.
  • If you plan to “only” make changes to the stylesheet, then use a plugin for editing CSS (no child theme needed). If you use Jetpack, this has a feature to edit CSS.

When making core theme file changes with a child theme, this is done by copying the file from the parent theme and uploading it to your child theme, while maintaining the same file structure as the parent theme. So for example, if you wanted to modify the header.php file in the parent theme, you copy that file and upload it to your child theme to the exact same location as the parent theme.

Note:The child theme duplicates the same structure and layout as the parent theme.

Install The Child Theme

Before you install the child theme, always make sure the parent theme is installed. It does not have to be activated, just installed, otherwise you will get an error.

  1. Go to Appearance >> Themes >> Add New >> Upload >> Choose File
  2. Locate the original downloaded (and unzipped) preferential-package file
  3. Inside, select the file “preferential-child.zip” and click Install Now
  4. Activate the theme

Attention:

When you activate a child theme, WordPress will see this as a “NEW” theme activation. Therefore any theme options you set with the parent theme will NOT be inherited by the child theme; you have to do them over again.

Screencast Tutorial

Video coming soon.

Categories: Setup Tutorials for Preferential

Leave a Reply