What is Child Theme?

A child-theme is a theme that inherits the functionality and styling of another theme, called the parent theme. Child themes are the recommended way of modifying an existing theme. You can make changes in child theme and also update parent theme; child-theme changes won’t get lost by updating parent theme. Read more about child-theme in WordPress codex.

In the simplest form, child-theme behaves different files in three manners:

  1. Files (images, .php files, .js files, etc.): When you create a file in child-theme with exact the same path and name of parent theme, this new file is overriding parent theme file. For example if you create a single.php in child-theme, it overrides parent single.php. When a file is called, WordPress scans child theme at first for that, if the file doesn’t exist there, goes to parent theme.
  2. functions.php: Functions in functions.php of child will be added to functions.php of parent.
  3. CSS: Child CSS codes will be added to parent CSS, in the case of similarity, child CSS overrides parent CSS.

Why Use a Child Theme?

There are some reasons why you would want to use a child-theme:

  • Secure Your Changes: If you modify a theme directly and it is updated, then your modifications may be lost. By using a child-theme you will ensure that your modifications are preserved (Modifications means changes you made directly in theme files).
  • Develop Faster: Using a child-theme can speed up development time specially when you are developing one theme for several websites.
  • Learn WordPress: Using a child-theme is a great way to learn about WordPress theme development.
If you want to make changes in your theme files, do it in child-theme, because Publisher regularly receives update and your changes won’t get lost when you update parent theme.

How to Create and Install Child Theme?

WordPress.org did a good job in describing how to create a child-theme BUT Publisher users receive a ready Child Theme in purchased package, unzip package file and go to Theme Files, here you see publisher-child.zip. Installing this ready-to-go Child Theme is similar to parent-theme installation but we review it here:

1- Install Child Theme via WordPress

  1. Navigate to Appearance → Themes.
  2. Click Install Themes and hit the upload button
  3. Navigate to find the publisher-child.zip file on your computer and click Install Now.
  4. Wait till the child-theme file gets uploaded and installed.
  5. Activate the newly installed theme. Go to Appearance → Themes and activate Publisher Child Theme.

2- Install Child Theme via FTP

  1. Connect into your host server via an FTP software.
  2. Unzip the publisher-child.zip file and ONLY use the extracted publisher-child theme folder.
  3. Upload the extracted publisher theme folder into wp-content → themes folder.
  4. Activate the newly installed theme. Go to Appearance → Themes and activate Publisher Child Theme.

An Important Note

Do not add @import url(“../publisher/style.css”); in CSS file for importing parent stylesheet! Publisher adds it dynamically for better browser caching mechanism.

How to Use Child-theme

Functions

Go to publisher-child folder and add your function to functions.php file and save the changes.

CSS Codes

Go to publisher-child folder and add your custom CSS codes to style.css file and save the changes.

PHP, JS & Image Files

If you want to override one file of parent-theme with these formats, you should create a file with the same name in the same exact path in child-theme. For example:

Your parent-theme file is off-canvas.php in this path publisher/views/general/header

Create off-canvas.php file in publisher-child/views/general/header

Definitely you should create these directories (i.e. views/general/header) in child-theme because there is no folder in it at first.