28

Creating a Child Theme

Unless you have a WordPress theme built specifically for you, it's unlikely you'll get exactly what you want in any theme you choose, and that means customizations. The problem is, no matter how small the customization, you run the risk of the theme getting updated sometime in the future, which may mean having your files automatically updated, which, in turn, means losing all the changes you made. The answer to this and other issues of customization is to create what's called a child theme. This is a theme that lives primarily off the files of the parent theme, but introduces files of its own whenever it needs to make changes to the parent.

In this lesson, you not only learn about the power of these types of themes, but you create your own child theme using the default WordPress Twenty Ten theme as its parent.

WHAT IS A CHILD THEME?

The concept of a child theme grew out of the realization that often, the changes people wanted to make to a theme were fairly minor. For example, they just wanted the header area to be smaller or the menu placed in a different spot, or they needed some extra widget areas. All of these changes can be made with a few adjustments to just a few files.

So the WordPress developers came up with a simple answer: a theme hierarchy.

If the necessary files don't exist in your theme, the system will look in another. As long as WordPress knows who the parent is, the child can use whatever files it needs to, and what it doesn't have, the ...

Get WordPress® 24-Hour Trainer, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.