5 Reasons You Should Use a WordPress Child Theme.

Foreword:

The first thing I do when I start working on a new website I search for a theme that fits the projects needs and create a child theme for it. WordPress is a very powerful platform, it is estimated that 30% of all websites in the world runs WordPress. WordPress is extremely flexible with millions of plugins and themes available, and S.E.O. friendly. A child theme is basically a theme that uses the parent theme and you are being able to override the parent theme look and behavior.

Twenty Twenty Theme

 

What exactly is a WordPress Child Theme?

WordPress Logo

In plain English, a WordPress child theme is a theme that declares the “parent” theme which it depends on and gets most of its functionality from. By telling WordPress that it is a “child” of some other theme, a theme saves itself from having to contain all the features and functionality that a full-fledged theme does, while still offering the convenient ability to make its own CSS, or even overwrite specific page templates of the parent.

 

5 Reasons every blogger should use a Child Theme.

1. You want to be unique & different

When you install a theme from WordPress Themes you are going to look the same as the hundreds or thousands of other websites that installed the same WordPress Theme as you. You always want to be unique and different from all the other websites. And a Child Theme gives you the ability to change all aspects of your website from functionality to the design.

 

2. You have more control

Down the line you may want to change the design. For example you want to add a menu to a different location or just change the look, or want to disable a certain feature, or increase the size of the header. With a child theme everything is possible. It gives you total control on how your website looks.

 

3. Stay consistent.

Never edit WordPress Theme files directly.

When you edit the “Parent” WordPress Theme files it will get overwritten when you update the Theme and all your edits are undone. And we certainly don’t want that to happen when your website is live, because all the changes you applied to the theme will be undone. A Child theme will avoid this because you are not editing the parent theme. You can also do edit the themes locally using a LAMP (Linux Apache MYSQL PHP) as described in my other article.

 

4. Adding “new” features the parent Theme doesn’t offer

With a child theme adding different fonts, icons, different layouts, is a breeze. WordPress has great documentation on how to enqueue styles and scripts, add or alter support for certain WordPress functions.

 

5. Learning new things about WordPress and the Themes

Working with a WordPress child theme is a great way to learn on how WordPress works in a fun way. if you don’t like the child theme you can go back to the regular theme.

 


 

Lets get to business

Sounds great! How do I make a Child theme?

A WordPress Child Theme consists of 3 file. We use the latest twentytwenty theme as an example for this child theme. First we have the folder name twentytwenty-child and in the folder we have a .css file thats called style.css and a .php file called functions.php.

In the style.css file we add the following. This is where we change the font family, size, colors, styles.


Theme Name: Twenty Twenty Child
Theme URI: http://example.com/
Description: Child theme for the Twenty Twenty theme
Author: Your name here
Author URI: http://example.com/about/
Template: twentytwenty
Version: 0.1.0

Then we upload these files with a ftp program for example FileZilla. Go to your WordPress admin and activate the child theme named Twenty Twenty child.

 

Problems overriding the parent theme?

Sometimes themes require some extra code to override the parents theme style properly. To override it add the following code to functions.php to re-enqueue the style sheets. So you don’t have to use !important all the time in your style.css


<?php
/**
* Theme functions and definitions
*
* @package Twenty Twenty Child
*/

if ( ! function_exists( ‘twentytwenty_enqueue_styles’ ) ) :

function twentytwenty_enqueue_styles() {
wp_enqueue_style( ‘twentytwenty-style-parent’, get_template_directory_uri() . ‘/style.css’ );
wp_enqueue_style( ‘twentytwenty-style-child’, get_stylesheet_directory_uri() . ‘/style.css’, array( ‘twentytwenty-style-parent’ ), ‘1.0.0’ );
}

endif;
add_action( ‘wp_enqueue_scripts’, ‘twentytwenty_enqueue_styles’, 99 );

 

This should solve the problem overriding the parent style unless styles. Now you can start overriding the parent theme, and give your unique looks.

 

I hope this guide was helpful and gets you on the right track.

Feel free to drop a comment below. And don’t forget to follow us on facebook and Pinterest!

Have fun Coding!

COMMENTS