#WordPressWednesday: Creating a basic child theme

In WordPress, the right theme can make all the difference. Between those that add functionality to ones that completely redefine the visual experience for a user, a good theme can make a great experience for a user.

However, sometimes you want a small change. Instead of a certain font, you want another one. Instead of one color, you’d prefer a different choice. And sometimes you want to change something, anything, but you don’t know how to go about it.

Luckily, in WordPress, there is a simple answer to many of these issues: a child theme.

The relationship goes like this: a child theme inherits the same functionality, styles, and layout of a parent theme, but can override any or none of this. Through using new files or establishing different styles, a child theme can look almost like its parent, but have slight variations.

To create a basic child theme, you need two files: style.css and functions.php


[gist https://gist.github.com/videlais/d414d8a9b891382072db /]

Note: Line 6 is where you substitute the parent theme name. It needs to be the exact directory name of the theme, not the one in its description.


[gist https://gist.github.com/videlais/2bdfed03353674d84a90 /]

Note: As noted on the Child Theme page of the WordPress Codex, the above code is current best practice for including the parent styles in the child theme.

Testing the theme

Once you’ve added some styles or files, it’s time to test it.

Zip the files together. Using either the built-in functionality of your operating system or another program, combine the files together.

Note: The name of the file will become the name of its directory. Be careful in its naming.

Theme: Add New

From the Dashboard, go to Appearance –> Themes. Click on the “Add New” button.

Themes: Upload Theme

From the Add Theme page, click on the “Upload Theme” button.

Theme: Choose File

Click on the “Choose File” button, select the zip file using the dialog, and click on “Open” to close it. Finally, click on the “Install Now” button to install the theme in WordPress.

Once installed, it can be activated like any other theme.