Build a Child Theme in WordPress with 2 Files and 2 Minutes
One the best ways to get a website up and running quickly is to use a WordPress theme that already has the approximate look and feel and tailor it to suit your needs. But, one dangerous practice that many WordPress developers are guilt of is modifying the theme’s files directly. This is a big no-no! Even if it’s a simple theme like one of the stock WordPress versions of TwentyTwelve, child themes give you a powerful, simple way to make all the changes you want without any risk to having your careful design work wiped out by an upgrade-happy client.
Beyond the power of wordpress child themes, I want to show you my own methodology for quickly creating design changes to a theme. Using a couple of readily available tools, I can make design changes almost as quickly as they’re requested, save the changes in a child theme, and continue doing great, time-efficient design work.
Some of the tools you will need for this article are FTP, Chrome web browser, and a text editor. That’s it! As I’ll demonstrate, this process allows for fast site changes with no risk of losing your work with a theme upgrade, which is a common issue as more and more sites are using a few standard base themes for development.
What’s a WordPress Child Theme?
A wordpress child theme has all the characteristics, code, and functions of its parent. So, if you’re working with something like the Skeleton or Responsive theme, two awesome, free base themes, you can get all the benefits of the parent theme while adding your changes without directly modifying the base theme.
WordPress makes the child theme the primary source for code, so if you have CSS for a particular class in the parent theme that is modified in the child, the child theme’s CSS supercedes the parent. In short, you get all the good without worrying about an edit or upgrade breaking your theme.
Another huge, but overlooked, benefit of a child theme is that you have amuch smaller file that you can reference later. I’ve worked with scores of themes that have 2,000+ lines of code just in their CSS files alone. My child themes typically have under 200 lines, so it’s a lot easier to jump back into the code and find what I’m looking for to make changes.
Step 1: Create a WordPress Child Theme
If you haven’t worked with a child theme before, I understand the apprehension. Thankfully, they take a few seconds to set up — literally. Once in place, you have an easy way to change the site without modifying the theme’s core files.
Create a new PHP file and drop this code into it. I’m assuming you have the TwentyEleven theme, since it comes with almost all the WordPress installations in the last year or two.
You MUST name this file style.css
Theme Name: Twenty Eleven Child<br />
Template: twentyeleven<br />
Upload this file into a new folder within your wp-content/themes folder. It doesn’t matter what you name the folder, but good practice is to add a “-child” to the theme name you are creating a child theme for. So, in the above example, I would place my new child theme document into a folder called “twentyeleven-child”.
The above code doesn’t do anything as of yet. But, you will be able to see it in the Admin->Appearance->Themes section of your WordPress admin site. By selecting the child theme we just created as the theme for your site, you will be using the Twenty Eleven theme as your primary theme….
Read full article here.