Creating A Child Theme
The first step should be creating a child theme. If you ever plan on doing any customization at all, you should always start by creating a child theme as soon as you get started.
Child themes are themes which rely on the presence of a parent theme. They borrow as much functionality from the parent theme as possible. Your job is to overwrite bits and pieces of functionality where needed.
To create a child theme create a new folder in your wp-content/themes
directory. You can name it anything you’d like, I am naming mine divi-child
. Create two files in this folder: style.css
and functions.php
. In the stylesheet, paste the code below:
The next step is to make sure that styles of the parent theme are used in the child theme. In the past it was commonplace to include this within the stylesheet. This is not the recommended method, you should enqueue the parent stylesheet in the functions file, here’s how:
add_action( 'wp_enqueue_scripts' , 'my_enqueue_assets' ); |
function my_enqueue_assets() { |
wp_enqueue_style( 'parent-style' , get_template_directory_uri(). '/style.css' ); |
If you visit the Appearance section in the admin you should see your new theme listed. You can now activate it and visit the front-end. The result should be exactly the same as the parent theme. At this stage everything is handled by the parent theme, all the files, all the views, all the styles come from there.
Read the full article here.