It is necessary to create child themes for any theme customization on a paid theme, because if we don't, any update of the paid theme will erase them!

Important: only the files we need to modify have to appear in the child theme. The child theme uses what already exists in its parent theme.

How to create a Child theme correctly:

Step 1 - Create a folder


First of all, create a new theme folder named after the project, in wp-content/themes.

Example: cool-project

In this folder, create the following:

  1. A screenshot.png file (of the validated design) in 880px × 660px
  2. A style.css file, where to put the style differences from the parent theme
  3. A functions.php file, where to put customizations of the parent theme definitions, if necessary. Note, it has to contain at least the php openning tag
  4. Any other file / folder to adapt from the parent theme

Step 2 - The style.css file


The file must contain as a header the following lines:

/*
Theme Name: UNIQUE
Description: PARENT Child Theme
Author: Gopadma team
Author URI: https://www.gopadma.com
Template: PARENT
Version: 1.0.0
*/

Where:

  • PARENT = the name of the parent template folder
  • UNIQUE = the name of the new template (will appear in the Back Office themes selection page)

Step 3 - Adapt the functions.php file if necessary


To use the CSS of the parent theme, it is necessary to add the following code:

add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );

function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}

Step 4 - Modifying the files to our purpose


Any other file that needs to be modified according to the project can be.
In order to do that, just copy it and its folder into the child theme.