Creating and Using a Child Theme for WordPress
Have you ever wanted to take full control on your website and running them on your own? Well, WordPress helped us developers and site owners to customize websites. Plus factor if you are already familiar or working with languages like HTML, CSS, PHP and such. There’s nothing you cannot achieve and handle on your website design to fit your vision.
However, there is a possibility that editing themes and changing designs were done wrong all the time.
Many people have been editing their themes directly. It means that they are adding or editing files on their active theme’s directory which causes some problems. One of the biggest issues is that all changes or modifications made on the theme will be lost if the theme’s developer released an update. Issues here are: users will not keep their themes up to date and miss the new features and more the security, just to keep the changes. Alternatively, users will have to deal with the loss of data when the update is applied.
This is why you have to create and use this so called “Child theme”.
Child themes act as a clone of your original theme. However, with this, you will be able to make some changes without causing some problems to your current theme or original theme, or we should call it the “Parent theme”.
With the help of this Child theme, you do not have to create yourself a theme from nothing, instead of using what you already have. Then, you can update your theme (Parent theme) without losing customizations. Also, you can use every functionality that your original theme has while editing your design according to your needs and many more advantages.
Interested? Well, here’s how to create one.
These would be the steps on creating a Child Theme.
Take note: it can be performed directly on your server via FTP client. However, it is recommended that you set up everything locally, then zip your child theme and install it via ‘Theme’ on WordPress.
Step one. Create a folder on your /wp-content/themes/ named after your theme followed by ‘-child’.
Step two. Enter the folder you created then create a style sheet (CSS) file that will hold all your codes that determine the design of your website. Create a new file and name it ‘style.css.’ To make the style sheet work correctly, you have to paste these code from WordPress Codex. It is called ‘style sheet header.’ Then import your ‘style.css’ file using @import from your Parent theme.
/* Theme Name: Sample Theme Child
Theme URI: http://example.com/twenty-fifteen-child/ // change this to the Parent theme that you already have
Description: Sample Theme Child Theme
Author: Sample Author
Template: sample theme
Version: 1.0.0 */
Step three. Create a file ‘functions.php’. Create a new text file then name it ‘functions.php.’ This will contain all your codes that your website behavior will depend on. It will handle all added and changed functionalities plus your created function on your website. Also, you can create a function here that will import your Parent theme’s style sheet. It is another way of importing. Paste the following codes.
add_action( ‘wp_enqueue_scripts’, ‘enqueue_parent_styles’ );
function enqueue_parent_styles() { wp_enqueue_style( ‘parent-style’, get_template_directory_uri().’/style.css’ ); }
After these three simple steps, activate your newly created Child theme on WP Dashboard > Appearance > Themes and you are done! You just saved yourself from numerous problems or issues and your website design for possible errors.
Protects your customizations.
Helps you to save and prevent your changes from losing if Parent theme were updated.
Convenient to use.
You do not have to create a theme from scratch, and you can use existing functionalities.
Easy to set up.
Creating and setting up child theme is easier with three steps. Create a new folder, add style sheet and import style.css from the Parent theme. Lastly, create functions.php file.