The Purpose Of Child Themes

Published by | Add Comment

If you been in the WordPress world for any length of time you have come across the words Child Theme at least once or twice. And it’s a pretty could chance you have asked yourself “What are they talking about?” or “Do I really need one of those?”. Well the short answer to whether or not you need one is YES, without a question.

So what is a child theme?

A child theme is a theme that inherits the functionality and styling of another theme, called the parent theme. Child themes are the ideal way of modifying an existing theme without changing any of the parent theme files.

The files that reside in the child theme are identical to the parent theme. But any changes made in the child theme will override the parent theme so this method is great for any custom php or styles you wish to add.

***To make sense of the picture above WordPress will look for changes in the child theme and override those of the parent theme if it finds any.

So why should I use a child theme?

Using a child theme will prevent any of your changes from being overwritten during an update of the parent theme or WordPress. If you were to make changes to the parent theme in any way they will overwritten and all your hard work will be lost and let me tell you that is a bad feeling knowing you created something awesome just to have it vanish because of an update.

What does it take to make one?

To make a child theme you will need a style.css and a functions.php in order for your child theme to function properly.

You can make one manually or use a plugin to achieve the same effect. We will go over both ways today.

The manual way.

  • Create a folder and name it something like theme-name-child
  • Next create a style.css file and include the following. Note that the template name needs to be the same as the parent theme folder.
    /*
     Theme Name:   Theme-name-Child
     Theme URI:    http://example.com/theme-name-child/
     Description:  What is the theme about
     Author:       John Doe
     Author URI:   http://example.com
     Template:     Must be the same name on the parent theme folder
     Version:      1.0.0
     License:      GNU General Public License v2 or later
     License URI:  http://www.gnu.org/licenses/gpl-2.0.html
     Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
     Text Domain:  Theme-name child
    */

     

  • Now we need to enqueue the style.css file through your functions.php by adding this:
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css');}

     

Now you should have 2 files within your child theme folder. All that is left to is zip the folder up and install it as you would any other theme. For information on creating child themes manually hop over to WordPress.org.

The Plug-in Way

Now for those that like the less technical way and prefer to just click and have all the heavy lifting done for them you can try One click child theme and it will do all the things we discussed above.

To get started go to appearance > child theme and fill out the form.

Platform 5 Users

If you are a Platform 5 user you will find that there is already a child theme available for you to download and install from the extend area under Themes.

If you use this theme you must change the folder name or when this theme is updated your changes will be lost. By default the folder name is pl-framework-pagelines you should change it to something like pl-framework-mytheme to prevent it from being updated. (this will require you to FTP into the server)

To find out more ways to add your custom css safely read the post Adding Custom CSS To Platform 5.

I hope this was helpful if you have any questions feel free to leave them in the comments.

~Cheers

About the author

Aires Dagraca, is the creative force behind Dagraca Creative, a Web Design Company that focuses on bringing the best web experience to their clients. He also enjoys Gaming, Web Design, Graphic design and family time with his wife and kids.

A special note from the author.

iHeart pagelines

Leave a Reply

Your email address will not be published. Required fields are marked *


Let's build something great together.

iHeart PageLines

  • 7 Free sections
  • Tutorials and Tips
  • Great Support
  • Custom Sections
Join For Free !!!

Error: Please enter a valid email address

Error: Invalid email

Error: Please enter your first name

Error: Please enter your last name

Error: Please enter a username

Error: Please enter a password

Error: Please confirm your password

Error: Password and password confirmation do not match