If you are using WordPress one of the best methods that you can use to update your theme is to use a child one. You might be confused about what this is, but this is would allow the customization that you are creating to be saved into another folder rather than affecting the main one. Here are is everything that you need to know about how you can create your own child theme and why you should be using this using either the manual or the plugin methods.
What is It?
The first question that anyone is going to be asking is exactly what is a child theme? No, it isn’t a theme for your WordPress site that revolves around children, but instead it is a new folder where you can customize your current theme. The changes that you are making to this theme aren’t going to be affecting the parent or original theme. However, if there are any changes that are made to the parent theme, then they will be shown and reflected in your child theme no matter what changes you have made.
You would always need to think about what you are going to be making changes to and how you are going to want to do that. Making changes to the original template isn’t going to be wise, especially if you don’t know the code, so think about creating a child if you want to make it your own. This is important, so why not think about going this method rather than worrying about unwanted changes being added to your site if the maintainer of the original theme changes something?
Why Use This Type of Theme?
Another question that you are going to probably have is just why you should be using the child theme rather than a parent or original theme. However, if you want to modify the theme that you are using on your website, then this is the recommended and safest ways. This would mean that the changes aren’t going to be deleted if your parent theme that you are using is updated. This is critical if you are adding various customizations to the website that would take some time to create and that you don’t want to be updated later if the maintainer does something.
Also, another reason that you might want to consider using this type of theme is because you can always make the desired changes and then if you aren’t happy simply de-active it and use the parent one that you had in the beginning. Think about this before you start to make any changes, especially if you think that you might have to go back and use the original one. No matter what if you don’t want to deal with having to change everything back if there are updates made to the original, then you should go this way and make sure that everything is protected.
How to Create Your Child Theme
The next thing you are going to want to know is just how you should be setting up this child theme, which can be done either manually or through the use of a plugin. You should ensure that you now both methods and the steps that would be included so that you can try it both ways to determine which way is the best for your needs. If you are going to be doing it manually here are the first few steps to take, including:
- Creating a new folder with any name that you want to give it since it doesn’t matter what it is called, but only that the files are given specific names
- Create a new file within that folder named style.css
Open the new file and insert the required code and save it once the code has been added
/*
Theme name: Optimizer Child
Template: Optimizer
*/
- Next, you would want to create another file called functions.php and you would need to paste some code into that file as well, such as:
<?php
add_action( ‘wp_enqueue_scripts’, ‘enqueue_child_theme_styles’, PHP_INT_MAX);
function enqueue_child_theme_styles() {
wp_enqueue_style( ‘parent-style’, get_template_directory_uri().’/style.css’ );
}
?>
- Once both of those files have the new code inserted into them and they have been saved you are going to want to zip the folder and upload it into Appearance – Themes – Add New
- Now you are going to want to activate the theme
This method is simple and you are going to have to make sure that you are copying and pasting the code exactly as it is into the files with the appropriate names. This should only be done if you know what you are doing and if you feel confident that you can complete this work without making a mess out of it.
Creating Using a Plugin
- Download the chosen plugin that you are going to use to help you set up the child theme
- Log into the administration area of your website
- Select Add new from the plugins section
- Choose upload plugin in order to upload your chosen plugin and click active plugin
- Visit appearance – themes and ensure that you are choosing the theme that you are going to create the child theme for and that it is activated
- Click on the thumbnail of the theme and choose child theme
- Click on the configuration page for the child theme and create the author field, description and theme name
- Click the button create child