Contact Us Tel: +27 21 448 9843

WordPress Tip – Creating a child theme

A child theme allows you to change styles and functionality in a theme, but protects you from losing all your changes if you decide to upgrade the theme version at a later stage. For a thorough explanation of child themes, go read the official WordPress documentation about child themes. Today’s WordPress Tip simply explains the proper mark-up for the declaring your child theme in style.css.

style.css is the one and only required file in a child theme. It provides the information header by which WordPress recognizes the child theme, and it replaces the style.css of the parent.

As with any WordPress theme, the information header must be at the top of the file, the only difference being that in a child theme the Template: line is required, so that WordPress knows which theme is the parent of the child theme.

Here is an example information header of a child theme’s style.css:

/*
Theme Name:     Child theme name
Theme URI:      http: //example.com/
Description:    Child theme for the Theme name
Author:         Your name here
Author URI:     http: //example.com/about/
Template:       themename
Version:        0.1.0
*/

A quick explanation of each line:

  • Theme Name. (required) Child theme name.
  • Theme URI. (optional) Child theme webpage.
  • Description. (optional) What this theme is. E.g.: My first child theme. Hurrah!
  • Author URI. (optional) Author webpage.
  • Author. (optional) Author name.
  • Template. (requireddirectory name of parent theme, case-sensitive.
  • Version. (optional) Child theme version. E.g.: 0.1, 1.0, etc.

Taken from WordPress Codex – http://codex.wordpress.org/Child_Themes

There is a good step by step guide for creating your first child theme here.

, ,

Comments are closed.