Child Theming

If you have a theme you like but want to modify it, you have a couple of choices.

The first option would be to modify the actual theme files, but this is usually a bad idea because if the theme gets updated (which is possible as new versions of WordPress are released), you will lose all your changes when you update the theme.

Instead, you should create a child theme. This is a theme that inherits all of the code and functions of the parent theme but adds custom modifications to the CSS and possibly the PHP files.

In brief:

  1. Install parent theme.
  2. Create new theme folder (e.g. ‘jackietheme’) in same directory as parent theme: public_html > site directory > wp-content > themes >
  3. Create a new style.css file. This should be started with code that designates it as your child theme CSS file and also imports the parent css. Specifically:

    Start your style.css file with the following block of code:
    /*
    Theme Name: Your theme name
    Theme URI: Your website's URL (or the theme URL if you're distributing it)
    Description: Something that says how cool the theme is
    Author: This is YOU!
    Version: optional, but good to keep track of changes
    Tags: optional
    Template: the name of the parent theme as listed in theme directory (for example, use "twentyten", not "Twenty Ten")
    */

    After this code (note that it resides within the /* */ comment brackets) you will need to import the parent theme CSS:

    @import url(../twentyten/style.css);

    (replacing ‘twentyten’ with a different theme name if appropriate)

  4. Add or modify CSS styles as necessary. If you want to override the parent theme’s styles, you will need to include those style declarations in your style.css file (the browser will look to your child theme first for stylesheet rules, and will default to the parent theme if you do not specify anything).
  5. Do not duplicate the theme PHP files (especially the function file) unless you modify the files. In the case of the functions.php file you cannot duplicate code that exists in the parent functions.php file or the theme will break.

Pat Ramsey posted another explanation of child themes on the WordPress Austin website.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>