Add Child Theme Support to Any WordPress Theme

photo credit: Leeroy
photo credit: Leeroy

If you’re a developer, you may take for granted how easy it is for you to create a child theme for storing customizations separate from the parent theme. This one seemingly simple task can pose a significant hurdle for your average WordPress user. Without understanding the best practice of creating a child theme, users resort to cramming all changes into the active theme. This puts them in a vulnerable position when security updates are available but they cannot update without overwriting their changes.

Matt Gibbs, lead developer of FacetWP, has created a little project to help users with creating child themes. “Use Child Theme” is a simple drop-in PHP class that theme developers can use to alert their users to activate a child theme and automatically create one for them.

“Normally, themes have to point users to a child theme documentation page or link to a pre-built child theme zip,” Gibbs said. “Most users don’t even bother.”

Gibbs said the Use Child Theme project was built to make it easy for theme authors to support it. The project was also an offshoot of his experiences supporting FacetWP.

“I do a lot of plugin support, and this issue keeps coming up over and over,” Gibbs said. “Users are on super old theme versions and they’re afraid to upgrade because they’ve modified the parent theme at one point, and don’t want to lose changes.”

The idea behind Use Child Theme is to automatically create a child theme for someone who otherwise might not know how to create one. It’s not a plugin but rather a tool that theme developers can opt to include with just one line in functions.php:

[php light=”true”]include( dirname( __FILE__ ) . ‘/use-child-theme.php’ );[/php]

WordPress theme developers, is this a method you would consider using to prompt users to activate a child theme? Or would you rather rely on links to documentation and/or a download link to a pre-built child theme?


14 responses to “Add Child Theme Support to Any WordPress Theme”

  1. Hi

    There is no reason for any website owner to stay on a old theme when customisations are in place. There are two pretty good programs to find all their customisations by doing a compare old theme original against old theme modified and redo them to the new theme release by a compare old theme modified against new theme original.

    They are called winmerge and beyond compare. I use them on a daily base to compare code of themes and plugins and redo changes.

    Best regards, Neo

  2. I had to try this out, so I added the code to one of my themes and tried it out…long story short, this is a very cool option to add to themes. I know there are a lot of people who are new to WordPress, especially theme modifications, let alone creating a child theme (which can be challenging). Normally with my premium themes I include a premade child theme, but for the free versions, we cannot add child themes to the install package.

    On my first try, I clicked on activate child theme and sure enough it literally created a child theme and activated it at the same time. One thing I did was modify the screenshot path for copying a custom child theme screenshot located in the parent theme’s image folder….it worked!

    There is one item of thought that would be an awesome addon would be to import the parent theme Customizer options should a user already have settings already set like colours, blog style, etc.

    Overall, this is a very nice function to offer newbies by simply clicking on a link to create and activate a child theme.

    • @Gunnar That plugin also looks cool! It’s good to see more developers addressing this problem. My custom theme has a child theme generator built in. When the theme is activated, it checks if parent or child. Throws a dismissable for user to deactivate parent, activate child. Then, run the child generator if child ! exists. Simple solution. I like Matt’s 178-line class tho.

  3. Child theme is an attractive concept and apart from WordPress, other enterprise web content management services like Sitefinity CMS, Drupal etc also follows this concept with the name of sub-theme, however no one is as good as WordPress. Child theme is a theme inherited from a build theme with additional features added by a company to suit their business requirements. WordPress allows to reuse this child theme with different websites and also can be shared to the community. The concept saves time and cost of buying multiple themes for different websites.
    Thanks for sharing useful information to help developers to define a child theme effortlessly.


Subscribe Via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

%d bloggers like this: