Feature image for the need to know about wordpress child themes

In this article, I hope that I clarify the idea about WordPress child themes, the uses of a child theme, and how to create a child theme. 

this out a doubt, the most common questions clients asked me about WordPress child themes are: 

  • What is a WordPress child theme?
  • When do you need to create a WordPress child theme?
  • Why do you need a child theme?
  • What are some of the advantages and disadvantages of a child theme?
  • How to create a child theme?

What exactly is a child theme

A WordPress child theme is a WordPress theme that inherits the functionality and style from a parent theme. WordPress created the ability to create a child theme. Because any customization or functions added to a theme would be erased or could break the website whenever the user would have to update. An update is essential for security and the prevention of others hacking into your site. 

With a child theme, you can keep the customization done to your theme and continue to update your parent theme without losing your work or being available to hackers. 

This is the most significant benefit of having a child theme.

To learn more on how to customize your WordPress website. This article will help you achieve the design you want.

THIS IS HOW TO USE ADDITIONAL CSS BOX IN WORDPRESS

Why and When should you use a WordPress child theme?

Using theme frameworks helps designers and developers decrease the production time for creating a website that meets the clients’ needs. There are few occasions when creating a theme from scratch is beneficial, but it is unnecessary in most cases. 

Suppose users are going to customize and make tweaks to there CSS or functions of their WordPress site. In that case, requiring a theme to have a child theme is necessary not to lose your work when you update your parent theme. But if you are going to stay within the limits of the theme’s features, a child theme may no be necessary but would still be a good idea to do anyway. 

On top of everything else, another reason why using a child theme is great to have is because it acts as an extension to the parent theme. The user or developer can create a header.php, footer.php, templates, JavaScript, and CSS file and not worry about affecting the parent WordPress theme. Theoretically, the user can have more files than the parent theme and not worry about losing your work when updating. But if this is the case, I would recommend finding a parent theme with the functionality you need. 

What are the advantages and disadvantages of using a WordPress child theme? 

The advantages of using a child theme are

  • You can safely update your theme regularly.
  • Creating a child theme allows you to have the capability of creating a website that meets your exact needs.
  • It is excellent to have as a fallback just in case a custom functionality breaks. You can away go back to the original function. 

The disadvantages of using a child theme are:

  • There is often a kind of learning curve associated with the parent theme because each theme has its hooks and filters that make up the theme itself. 
  • Another disadvantage comes from the parent them. When dealing with clients’ WordPress websites where the framework’s developers abandon, I have run into many situations, lose interest in maintaining or get acquired by a different development company. 

How do you create a WordPress child theme? 

Fortunately, I have noticed a trend where themes are starting to come with their WordPress child themes attached. This is awesome because it saves you time.

But if a WordPress child theme is not available, then there are two popular methods to creating a WordPress child theme. 

  • Manually create a WordPress Child Theme through FTP or CPanel File Manager
  • Use a WordPress child theme plugin

Manually create a WordPress child theme.

locating the theme folder
  1. Either in your File Manager in your CPanel or through FTP, head to the Public_html > wp-content > themes folder. 

2. Create a new folder within that theme directory. I usually name the child theme after the parent them but attach the child theme afterward like in this example. I turn twentytwentyone into twentytwentyone-child. Do not use spaces for naming. 

3. Using a text editor like Sublime if you are using FTP or in your file manager’s text editor, create a file named style.css and add the following code. 

/* 
Theme Name: Twenty Twenty-One Child 
Theme URL: http://yourdomain.com
Description: This is the child theme of Twenty Twenty-One
Theme Author: Your Name
Author URL: http://yourdomain.com
Template: twentytwentyone 
Version: 1.0.0 
Text Domain: twentytwentyone-child 
*/

4. Make the necessary changes to the code to fit the child theme you are creating for yourself.

5. In the same directory, create a new file named functions.php and the following code inside the file.

<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
   wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>

6. After this, log in to your WordPress website and make your way to the themes page. If done correctly, you should see the WordPress child theme.

How to create a WordPress child theme using a plugin. 

Image of the WordPress dashboard
  1. Head to the Plugins page in your WordPress dashboard.
Image of the WordPress dashboard

2. From your plugin page, navigate to “add plugin.” For this example, in the search bar, type child theme. I will be using “Child Theme Generator” to create our WordPress child theme. Install and activate the plugin. 

WordPress plugin page showing Child Theme Generator

3. From the plugins page, locate the “Child Theme Generator” and click on the “Create” option. 

selecting the WordPress theme from the drop down menu

4. In the drop-down, locate the theme that you want to use to create the WordPress child theme. In this example, we are going to continue to use the Twenty Twenty-One theme.

filling in information to create the WordPress child theme

5. In the “Heading,” type the name you want to give your WordPress child theme. Here I typed “Twenty Twenty-One Child,” and for the “Description,” I placed a description about the child theme being created, “This is the child theme for Twenty Twenty-One Theme.” After you are done filling in the two fields, create the new child theme.

finalize the Child Theme installation and activation

6. Check the “Activate child-theme” box and then click the finished button.

preview of the WordPress Child theme

7. Go to the Themes page in your dashboard, and you should see the new child theme created and activated. 

Conclusion

I hope you now have a good grasp of the importance of a WordPress child when to use, the pros and cons, and how to create a child theme for your WordPress website. My goal for this article is to provide easy to consume knowledge about WordPress and Web Development. 

Please share if you found this article helpful!

contact me

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply