Creating a Child Theme in WordPress

A child theme is a theme that inherits the functionality of the parent theme. The main advantage of using a child theme is that by updating the theme you will not lose the modifications you have been able to make.

To start we have to access, via FTP, the WordPress file system and create a folder in / wp-content / themes /. You can put the name you want but I recommend putting a name that refers to the father.
For example: if the father is called the main subject, the son would put the main-son.

Already inside the folder of the child theme we would create two files: style.css and functions.php.
We will edit the style.css file and write it:

  Theme Name:   maintheme child
  Template:     maintheme
  Author:       Manu Doowebs
  Description:  child theme of maintheme
  Version:      1.0.0
  Text Domain:  miantheme-child

/** here your custom styles  **/

Now I will explain the fields that I have used:
Theme name: Name of the child theme.
Template: the name of the directory where the parent theme is.
Author: Author of the creator of the son theme.
Version: Version of the child theme.
Domain text: This field is used to make a topic translatable. It is not necessary to put blank spaces, since it will be an identifier for the translation.

For what inherits the main theme styles, to functions.php we will have to put:


add_action( 'wp_enqueue_scripts', 'get_styles',20 );
function get_styles() {
    wp_enqueue_style( 'main-theme', get_stylesheet_directory_uri() . '/style.css' );

Now you just need to activate the theme just like any other topic and so we can make the changes we believe necessary, without fear of losing them for an update.