The child themes

child themes

Although we have a lot of available predefined themes, both free and paid, often advanced users may wish to make some modifications. Sometimes it comes to small changes, adding new styles, color change, but sometimes change is required serious concern new features. Modification of the original theme is not a good idea. Most of the better themes will be regularly updated by the authors, if only to take advantage of the new version of WordPress, or patch any bugs and vulnerabilities. If the new version will include changes to the files that we modify our extras disappear, because the files will be replaced by those from the newer version.


To avoid such problems and allow users to safely develop themes we have a special mechanism to create a child themes. It is almost always sufficient for such purposes. If the original theme was well written, in accordance with art and recommendations of the WordPress Codex, we should not encounter any major problems.

How to create a child theme

Create the new directory with the the name of the child theme in wp-content/themes/directory and add the style.css file. In the style.css file put the following code:

/*
Theme Name: Name of theme
Template: nameoftemplate
Version: 1.0.0
Text Domain: nameoftemplate-child
*/
 
/* CSS */
@import url('../nameoftemplate/style.css');
 
/* put the CSS below */

If you do not want to useimport to load the CSS from the base theme, we can use another method. To do this, create a functions.php file and then add in the following code:

add_action('wp_enqueue_scripts', 'child_theme_css’);
function child_theme_css() {
wp_enqueue_style('parent-theme-css', get_template_directory_uri() . '/style.css');
This is a more elegant method. At this point it is worth mentioning an important issue – the way overwrite other files in recital child – outside the CSS code can also modify other files – just copy the file to the theme of the child, taking into account the structure of the directory, and then modify it.
If you only intend to modify the CSS theme and don’t like editing files using the FTP protocol, you can use the solutions that allow us to override the theme CSS code in such a way that they do not lose your changes when you update the theme.
One of these solutions offers JetPack plug in a module called Custom CSS.

Image source: featured image