Child Theme Creation 101
From Headway Codex
Contents |
Using Child Themes for Custom CSS (Video)
Choosing a Code Editor
Before creating a child theme, you will need a plain text editor. 'An application used to create documents such as Microsoft Word, Apple Pages, or Wordpad will not work in this situation. Notepad for Windows and Text Edit (in Plain Text mode) for Mac are available on virtually every Windows and Mac computers out there.
If you want a more robust coding environment we recommend the following editors:
- TextMate (Mac) (Premium)
- Coda (Mac) (Premium)
- Espresso (Mac) (Premium)
- Notepad++ (Windows) (Free)
- Aptana Studio (Universal) (Free)
- NetBeans (Universal) (Free)
Child Theme Requirements
A WordPress child theme requires only one file, but we recommend you at least have the following:
- style.css (The only required file)
- functions.php
The style.css file contains the information that will tell WordPress what the name of the child theme is, the fact that it's a Headway child theme. You can also place any actual CSS you want the child theme to display too.
The functions.php is for inserting PHP. This file is perfect for using Headway Hooks. Please note, anything in the child theme functions.php will be executed before any of Headway's files.
Creating style.css
To create the style.css, you will need to open up a plain text editor of choice and create a new file named style.css.
Then, insert the following:
/* THEME NAME:Headway Child Theme THEME URI:http://www.headwaythemes.com VERSION:1.0 AUTHOR:Headway Themes AUTHOR URI:http://www.headwaythemes.com DESCRIPTION:This is an example. TEMPLATE:headway */
You can edit the Theme name, URI, Version, Author, Author URI, and Description. However, do not change the TEMPLATE line. That's the important bit that tells WordPress it's a child theme of Headway.
Once you're done filling out that information, save the file as style.css (make sure it doesn't save as style.css.txt by accident).
Creating functions.php
Then, create another file. This'll be our functions file. Save that as functions.php (again, not functions.php.txt).
Headway 3.0 has a lot of the hooks it used to have in Headway 2.0.13. However, the Headway 3.0 Easy Hooks plugin isn't available yet, so here's a little PHP to get you started with the functions.php file. There's a hook for inserting stuff into the opening of the footer block.
Insert this into functions.php:
<?php
function insert_links_footer() {
?>
<!-- Insert your HTML Here, dude. -->
<a href="#">my link</a> <br />
<a href="#">my link</a>
<!-- Stop with the HTML now! -->
<?php
}
add_action('headway_footer_open', 'insert_links_footer'); //Tells WordPress to run the insert_link_footer() function when Headway's ''headway_footer_open'' hook is called.
?>
Child Themes API
Read more about the specific options you have with the Headway Child Theme API
Final Steps
Once you have created the two files, put them inside of a folder and zip the folder up. Then, upload the child theme zip and activate your child theme. Here's an example one we've created to help you out.
That's all—you've just created a child theme for Headway!