Create a WordPress Child Theme For Easy Customizations

blank

When creating a new WordPress site, one of the most important steps is to use parent and child themes. Child theme support has been greatly improved with WordPress 3.0 and it’s highly recommended when you customize a theme for your site.

A child theme inherits the functionality of a parent theme and it keeps all of your customizations in their own folder. In this case when you update your theme to newer versions without overwriting your customizations, all of the customizations you’ve made will be preserved within the child theme.

Create a Child Theme

Create a new directory in wp-content/themes, and name it twentyeleven-child (or anything you like).
This directory can contain as little as a style.css file with child theme details and indication of the main theme it will inherit from (required), and as much as any full-fledged WordPress theme files (optional)
Edit the CSS with the following info:

/*Theme Name: Child Theme twentyeleven (required)Theme URI: http: //example.com/ (optional)Description: Child theme for the Twenty Eleven theme (optional)Author: Your name here (optional)Author URI: http: //example.com/about/ (optional)Template: twentyeleven (required)Version: 0.1.0 (optional)

Right after that, add the line: @import url(“../twentyeleven/style.css”); replace “twentyeleven” with your main theme details – There must be no other CSS rules above the @import rule. If you put other rules above it, it will be invalidated and the stylesheet of the parent will not be imported.
Note on RTL support – To support RTL languages, add rtl.css file to your child theme

Using functions.php in WordPress child theme

Unlike style.css, the functions.php of a child theme does not override its counterpart from the parent. Instead, it is loaded in addition to the parent’s functions.php. (Specifically, it is loaded right before the parent’s file.) In that way, the functions.php of a child theme provides a smart, trouble-free method of modifying the functionality of a parent theme.

More detailed tutorial on How To Create a child theme (WordPress)

Leave a Reply

Your email address will not be published. Required fields are marked *