As a WordPress website owner you’ve likely thought of tweaking your theme to make it appear to be unique, to add some custom functionality to it, or simply to try out different calls to action.
Fortunately, there is an easy way to modify your theme’s design and functionality without worrying about losing your customizations: child themes. They allow you to preserve theme modifications and can even speed up your next WordPress development project.
With this in mind, in this post, we’ll talk about what child themes are and how they work within the context of WordPress. Then, we’ll walk you through a quick tutorial to show you how you can create and customize your own child theme – the right way.
THE BASICS OF WORDPRESS CHILD THEMES
A child theme is essentially a theme that automatically inherits the design and functionality of another theme which we’ll call its parent theme.
When you activate a child theme on your website, WordPress will check to see if it has code for design or functionality in it. Since the functionality coded into the child theme overrides that of the parent theme, you’ll see the child theme’s design and functionality reflected on your website.
On the other hand, if the child theme doesn’t contain any code for implementing or modifying existing functionality then WordPress will refer to the parent theme’s files and apply those to your WordPress ,Wordpress Website Development Florida.
Simply put, child themes are the themes that you add code to whenever you need to modify your theme’s design or its functionality. Here are a few reasons why you’d want to use child themes:
The changes you make to your theme’s files directly will be lost whenever your update the (parent) theme.
Having separate files for custom code snippets
will help you keep track of the modifications
you make to your theme.
Child themes inherit functionality from their parent themes which eliminates the need to rewrite chunks of code and speeds up development time.
Now that you’re familiar with what child themes are and why it’s a good idea to use them in your next WordPress development project, let’s take a look at how you can create your own.
HOW TO CREATE A CHILD THEME IN WORDPRESS
Although most high-quality themes come with child themes right out of the box, it’s a good idea to know how to create one manually in case yours doesn’t or you’ve already used up the free child theme. The good news is that creating a child theme is super easy – even if you’re not particularly technically inclined!
To get started, you’ll need access to your site’s cPanel (or an FTP client) and a text editor. For the purpose of this tutorial, I’ll create a child theme for the Twenty Seventeen theme and create its files using cPanel.
STEP 1: CREATE A NEW THEME DIRECTORY IN YOUR WORDPRESS INSTALL
To kick things off, log in to your cPanel account (or FTP client) and navigate to your site’s theme directory. It should be located in /wp-content/themes.
Next, create a new directory for the child theme and name it twentyseventeen-child. Giving the child theme the same name as the parent theme with a -child appended at the end is in line with the best practices.
STEP 2: CREATE A STYLE.CSS FILE FOR YOUR CHILD THEME
By now you should have an empty theme directory for the new child theme. In this step, we’ll create a stylesheet for it and add some code in it that’ll define its name and its parent theme. The code will also import the parent theme’s style sheet to the child theme
Note: If your theme has multiple style sheets (yes, that’s entirely possible) then you’ll have to add the corresponding code snippet given in the following step, too.
Open up the new child theme directory (i.e. /wp-content/themes/twentyseventeen-child), create a new file in it, and name it style.css.
In the lines of code given above, the values for Theme Name and Template define the child theme’s name and tell WordPress which theme to consider as the parent theme respectively. The @import line adds the parent theme’s CSS rules to the child theme which means that when you activate the child theme to your website you’ll be able to see both the content andits styling.
At this stage your child theme is (technically) ready to go. If you’re only going to make stylistic changes to your site’s theme then you can skip down to Step 4. However, if you think that you may need to modify your theme’s functionality or add custom functionality to it then you’ll need to add a functions.php file to your child theme’s directory.
Make sure not to miss a single video, Click here to Subscribe:
Zenerom Creative Lab