Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

How to Create a Child Theme for a Site that Already has a lot of Customization?

I just took over a bunch of old WordPress sites that have no child themes. The sites are heavily customized and not just in the styles.css file. Header.php, functions.php are all suspected to be modified. My best idea so far is to copy all the suspected files into the child theme file, but I haven't been able to find any well documented way of how to do this. I want to make sure I get these sites up to date and don't break them.

1 Answer

Colin Marshall
Colin Marshall
32,861 Points

First off, do all your work on these sites locally instead of on the hosting server. That way if something breaks when you are making the switch to child themes, it won't have any effect on the live site. Make backup copies of their theme folder because you can lose all their changes if you run an update on theme by accident.

Once you are setup locally, download a fresh, untampered copy of the theme they are using. There are tools out there that allow you to compare two folders and find the differences in the files (Google file comparison tools). This part will be tricky because if the theme version they have is older than the one you downloaded, you will see differences from updates to theme as well as the developer's customizations.

Ideally you will want to compare the differences between themes of the exact same version, so it might be worth it to contact the theme developer (the people that actually made the theme, not the guy who customized it) and see if you can get ahold of an older version of the theme that matches the version you are working with. If you can get the exact same versions, the file comparison tools will show only the customizations that were made to the theme.

From there, like you said, just copy over the theme files that have differences to the child theme, and then replace the parent theme with a clean, untouched copy. Once everything looks good locally, transfer the new parent and child theme files to the live server, and select the child theme for use.