WordPress Child themes – why, where and how to use

wordpress child theme
wordpress child theme

Child theme is a topic which has been talked, discussed and written a lot and yet is very important for every WordPress Developer. I personally believe child theme is one of the many awesome features which makes wordpress what it is today.

Child theme can be basically defined as a theme which derived it features from a parent theme and allow the user to override the features/design from the parent theme which would remain conserved even after updates.

Child theme is one of my best practice for wordpress development, it becomes more essential for the user who uses a theme may it be free or premium and tend to customize it to make it match his/her needs and requirement.

Why to use child theme?

Because a user, however simple he wants his site to be, tends to make some changes and customizations to the theme, may it be a change in color, font size or image sizes and Updating wordpress, its plugins and themes are inevitable because everyone wants a better product.

If you do not use a child theme, you tend to loose all the changes made to the theme once you update your theme. But child theme can save you from this. So It is highly advisable to make a child theme of your parent theme and keep the customizations to the child theme.

Where to use child theme?

Child theme should be used in all wordpress projects which uses a theme which is not built from scratch for that respective project, which means if you are using a free theme from wordpress.org or any premium theme.

How to use child theme?

Creating a child theme is super easy. To make a child theme up and running the only required file is style.css. You need to add the file to the child theme folder with the following header.

Though the only required line was Template: twentytwelve, other add more details to the header.

After this add the below code to import the style.css of the parent theme

Once this is done you can move the child theme folder to the themes folder and the theme would appear in the Appearance > Themes. You will see your child theme listed there. Click Activate.

Once activated, the changes made to the child theme would reflect in the front end.

Template files
Using child themes you can also override the parent theme’s files like header.php, single.php etc.

To override the template files you need to copy the file to the child theme folder and make the changes to it and then save it. But the files which are in located in further sub folder, the customization of those files depends upon the child theme compatibility of the parent theme.

Template file like functions.php behave a little differently. Instead of overriding the parent theme’s functions.php, the child theme’s functions.php file loads prior to that. so both the functions.php file loads.

So Child theme is not only a good wordpress development practice but also a faster way of developing a site without the swords namely “updates” dangling over your heads(read customizations).

facebook-profile-picture

Maruti Mohanty

I am a happy go lucky WordPress Developer, who loves biking, movies and learning different languages

   

You may also like...

21 Responses

  1. Mark Joseph says:

    Good catch here and thanks for the tips Maruti. Do you also consider child theme if you are using multi-site under WordPress?

  2. Subh says:

    Nice basic piece of information. Even though its the basic of theme overriding, this is the most important !! Great article ๐Ÿ™‚

  3. suraj jaiswal says:

    great knowledge!

  4. ajiewp says:

    I will try this ….!!!

  5. it’s really helpfull post .

  1. September 12, 2014

    […] always I will advise to make the below codes to the functions.php file of your child theme to keep the changes […]

  2. September 16, 2014

    […] can use the filter in the following way in your child theme‘s functions.php […]

  3. November 6, 2014

    […] As we dont’t have hooks to deal with this, like always I will suggest to use child theme. […]

  4. November 27, 2014

    […] We can add the following lines of code to the theme’s functions.php file to make this work, and like always I would suggest to make the following changes using a child theme. […]

  5. February 7, 2015

    […] the active theme’s functions.php file, and having said that I will as always reiterate to use child theme to make these following […]

  6. March 3, 2015

    […] can be added to the theme’s or most appropriately I would say child theme‘s functions.php file to include only the contributors and not subscribers to the allow […]

  7. May 7, 2015

    […] Now you would have the caption with the featured image, add the custom styling to make it look the way you want and most importantly, don’t forget to make the changes using a child theme. […]

  8. August 12, 2015

    […] file. Needless to say but I would say it again, please please make your custom changes using a child theme, so add the below snippet in your child theme’s functions.php […]

  9. October 1, 2015

    […] can customize receiving the moderation/notification emails for comments. Use these snippets in the child theme‘s functions.php file. Let me know if there is any other way you want to customize it in the […]

  10. March 22, 2016

    […] Instead of changing themes’s style.css it’s recommended toย  use child theme. […]

  11. June 22, 2016

    […] can add this above code snippet in the themeโ€™s functions.php or pluginโ€™s main file to do the magic. Now all the images you upload to the media […]

Leave a Reply

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

%d bloggers like this: