
Child themes are very useful when you want to make changes on original themes. They are separate themes with your custom code. It's a good practice to create a child theme because you can be sure that your changes won't be overwritten after you update the original theme. You can also easily turn off your child theme and back to the original theme. How does it work? When your website is using a child theme WordPress will check your custom code first to see if a custom modification exists. If it doesn't, WordPress will use your original parent theme. This is awesome because you can modify only what you need. Creating a child theme is very simple. You just need to follow a few steps:
- Connect to your server using FTP protocol with the login information that you have from your hosting provider.
- Go to your
wp-content/themes
directory. - Create a folder with name
mdw-child
- The Open folder that you just created and create two files:
functions.php
andstyle.css
. - Now, open your style.css file and paste the following code:
- You can modify this code, but be careful. The two important lines in the code above are
Theme Name
andTemplate
. TheTheme Name
tells WordPress what is the name of your theme.Template
tells WordPress which theme should be used as a parent. - Open
functions.php
file and paste following code: - Login to your admin dashboard and go to
Appearance > Themes
to activate your child theme. - To add custom
.css
classes edit the Child's Theme "style.css" file. You don't have to copy any other file from the MDW package. All the changes will be added from this file. Don't forget to copy "style.css into your FTP server.
/*
Theme Name: MDW Child
Theme URI: http://yourwebsite.com/mdw-child/
Description: This is my child theme for MDW
Author: Your name
Author URI: http://yoursite.com
Template: mdw
Version: 1.0
Tags: some, tags, goes, here
Text Domain: mdw-child
*/
<?php
function custom_theme_enqueue_styles() {
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css');
}
add_action( 'wp_enqueue_scripts', 'custom_theme_enqueue_styles', 11);
?>