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.
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

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?
The example in the Github repo only does CSS but you can include custom templates as well.
See here:
https://codex.wordpress.org/Child_Themes#Template_Files
So, if your parent theme has a single.php file, your child theme can also have a single.php file that will take precedence over the parent themes file.
See Template Hierarchy for more details on templates:
https://codex.wordpress.org/Template_Hierarchy