Building a WordPress Child Theme

Make changes to your theme the correct way

Whenever I’m using a pre-built theme and need to make changes to it, I create a child theme and then make all changes to that child theme.

A child theme inherits features from it’s parent theme. This allows you to make modifications to the child theme without affecting the code in the parent theme, which allows the parent theme to be updated as normal, without causing your modifications to be lost.

Benefits of using a child theme

  • If you modify an existing theme and it is updated, your changes will be lost. With a child theme, you can update the parent theme (which might be important for security or functionality) and still keep your changes.
  • It can speed up development time.
  • It’s a great way to get started if you are just learning WordPress theme development.

Creating the Child Theme

Only one file is required when building a WordPress child theme, style.css. The only required lines in style.css are Theme Name and Template. I typically use something like the following for my style.css file. Just set the Template value to whatever the name of your parent theme is. In my case, it’s independent-publisher.

Theme Name: longren.io
Theme URI: http://longren.io/
Author: Tyler Longren
Author URI: http://longren.io
Template: independent-publisher
Description: Independent Publisher is beautiful reader-focused WordPress theme, for you. Clean, responsive, and mobile-ready, it gets out of your way and lets you share what you create. Full support for all Post Formats. This theme is ideal for both single-author and multi-author blogs.
Version: 1.0
License: GNU GPLv3
License URI: http://www.gnu.org/copyleft/gpl.html

Example Child Theme GitHub Repository

I put together a simple child theme example, it’s available on GitHub.

Feel free to use it as a base for your child themes. It’s setup to include the parent theme CSS, child theme CSS, and the Font Awesome CSS. If you need help, you can ask in the comments at this post, or create an issue at the GitHub repository.

0

Well, now what?

Work with Me

I'm available for hire and always taking new clients, big and small. Got a project or an idea you'd like to discuss? Startup plan but no developer to make it happen? Just get in touch, I'd love to see if I can help you out!

Leave some Feedback

Got a question or some updated information releavant to this post? Please, leave a comment! The comments are a great way to get help, I read them all and reply to nearly every comment. Let's talk. 😀

Longren.io is proudly hosted by DigitalOcean

DigitalOcean

2 thoughts on “Building a WordPress Child Theme

  1. This is only for custom css?? If i want to change a code in some theme files is there a way to do it like this, or just editing the original file?

    0

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.