creare unei teme child in wordpress

Creating a child theme

You have created a site that you have customized to your liking with custom features. But after a while the theme you use automatically updates, which is a good thing. The more up-to-date the theme and plugins are, the less vulnerable the site is in terms of security. But updating a theme can also lead to the loss of custom features that you have made on the site, whether it is custom post types or editing function.php, archive.php, single.php files, etc .. By updating , we understand that the theme files are rewritten, respectively the existing code in them can be deleted and replaced with an improved one. Imagine a real estate agency website that has hundreds or even thousands of custom posts made with Advance Custom Fields for real estate ads. If the theme is updated, many of these items may not work properly or may no longer work.

Therefore, in some cases, especially for personalized sites, it is recommended to use a child theme. By child theme we mean a theme that uses all the CSS styles of another theme, hereinafter referred to as the parent theme. Thus, in case the php files of the parent theme are subject to an update, the custom elements developed on the site will no longer suffer if they are in the child theme files. As long as the child theme is not created by a developer outside of our site, who will improve it whenever he has the opportunity, it will remain at the stage where we customize it.

How to create a child theme in WordPress?

To create a child theme, we have two possibilities:

  1. Through a plugin such as Child Theme Configurator.
  2. Through the Cpanel panel. Using the Files Manager option, we follow the path of the folders as follows: “public_html / wp-contend / themes /”. In the “themes” folder we create a new subfolder that we name as we want. In this folder we create a file that we call style.css. The following code must be entered in this file and customized:
Theme Name: child theme name
Theme URI:
Description: short description 
Author: Author name
Template: parentthemename
Version: 1.0

You will need to replace the “child name” with the newly created theme name and the Theme URI address with that of your site as a developer (if you have, if you can’t delete this line or leave it blank, it is not required). In “Author” put your name, in “Template” the name of the parent theme, from which you want to inherit the stylization elements. If the parent theme is installed, the child theme will automatically generate the properties of its style.css file. Now we can add and customize in the new folder any file we want. We can also copy and customize from the basic files of the parent theme, such as functions.php, single.php or index.php, etc. In order to use the new theme, you will need to activate it from the main menu of the WordPress control panel by selecting “Appearance / Themes”.

To add a theme cover image we will need to add an image named screenshot.jpg to the created folder. WordPress will use it as the default image.