Customizing Theme Style with Child Themes

A WordPress theme consists of a collection of template files, stylesheets, images, and JavaScript files. The theme controls the layout and design that your visitors see on the site. When such a theme is properly set up as a parent theme, it allows a child theme, or a subset of instructions, to override its files. This ensures a child theme can selectively modify the layout, styling, and functionality of the parent theme.

The quickest way to understand child themes is by example. In this section, you create a simple child theme that modifies the style of the parent theme.

Currently, the default WordPress theme is Twenty Ten. Figure 5-1 shows how the Twenty Ten theme appears on a sample site.

You likely have Twenty Ten on your WordPress site, and Twenty Ten is child theme'ready; therefore, it's a great candidate for creating an example child theme. To keep the names simple, we call the new child theme TwentyTen Child (original, we know).

Creating a child theme

Like regular themes, a child theme needs to reside in a directory inside the /wp-content/themes directory. The first step to creating a child theme is to add the directory that will hold it. For this example, create a new directory called twentyten-child inside the /wp-content/themes directory.

Figure 5-1: The Twenty Ten theme.

image

To register the twentyten-child directory as a theme and ...

Get WordPress® All-in-One For Dummies® 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.