Article du fil d'actualités de CreaWeb2B

N'hésitez pas à commenter et partager

Birth of a child theme

by | 9 Dec,2016 | DIVI, Tutorials, WORDPRESS

Why you need a child theme and how to easily get one

A child theme allows you to do any customization to override the CSS and php of the parent theme.

Here i’m going to give you the way a add a child theme to the DIVI Theme (it’s the same way for any theme but here inside the CSS file, we are going to add the name of DIVI as parent template.)

No coding skills required, it’s just 3 easy steps to follow. No need for any plugin to add a child theme

1) Create a folder inside wp-content/themes/ named “name of child theme”

2) Inside this folder, create a file named style.css containing the child theme informations (copy/paste the code and add your personnal informations) :

/*
Theme Name: My Child Theme
Theme URI: Your URL
Description: Here goes the description of the child thme
Author:Your name
Author URI: link to your website
Template: Divi
Version: 1.0
*/

/* Custom css goes here */

3) Next create a second file (still inside the child theme folder) : functions.php containing the following code to enqueue style.css from parent theme (copy/paste the following php code) :

<?php // custom php 

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

?>

Of course you need to activate this child theme. Let’s go to : appearance -> themes and activate your custom child theme by hovering it and click on activate.

And… You have hardly reached the end and you got a fresh new child theme. Isn’t that easy ?