• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar

HANDS ON WORDPRESS

Making a Living with WordPress

  • Home
  • Blog
  • About
    • About Hands On WordPress
  • The Austin WordPress Community
  • Contact
  • Show Search
Hide Search
You are here: Home / WordPress / What is a WordPress Child Theme?

What is a WordPress Child Theme?

sandibatik · July 26, 2010 · Leave a Comment

Austin WordPress Meetup Notes — 7/26/2010

Pat Ramsey, Founder of the Austin WordPress Meetup, lead another great session about applying Best Practices to Theming a WordPress site this evening. As July seems to have been the month we all focused on all the new features in WordPress 3.0 and how those new features will effect how the user interacts with WordPress, it seemed a good time to answer all the questions that have been coming up about WordPress Child Themes.

As always, Pat started the class with his usual admonition that everything he was about to tell us can be found the the WordPress Codex. He reminded us that the Codex is the first, and best source to answer any question that you might have will working on your WordPress site.

First, what is a child theme. A WordPress child theme is a theme that relies on another theme being installed. A child theme can’t stand on its own. At the simplest, the child theme is just a style.css file with an extra commented line. That’s it.

Child themes have been in existence for a few years, they’re still not something the average WordPress user understands, but that’s changing and the topic is at the forefront of people’s minds when they’re thinking about their site’s design. WordPress users want to know if they should use a child theme instead of their existing theme, be it custom or prebuilt.

Pat started his demonstration using the Twenty Ten theme. He asked the group to look at the comment block at the top of that theme’s style.css:

/*
Theme Name: Twenty Ten
Theme URI: http://wordpress.org/
Description: The 2010 default theme for WordPress.
Author: the WordPress team
Version: 1.0
Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style
*/

For a child theme, you’d create a css file called style.css. You would have to place a comment block at the top of the file in order for WordPress to recognize it as a theme – with one extra line that begins with “Template”:


/*
Theme Name: My Awesomest Theme
Theme URI: http://123.com/
Description: Uber-awesomeness incarnate.
Author: Me
Version: 1.0a
Tags: optional
Template: twentyten
*/

That extra line “Template:” is what makes this a child theme. It has the directory name of the theme you want as a parent. In this case, Twenty Ten is going to be our parent theme. Its directory is named twentyten, so that’s the name we use in the Template line. If we activated My Awesomest Theme in the Appearance panel, (Remember, we only have the CSS file as our child theme – nothing else.) WordPress will use Twenty Ten’s templates for the site’s framework, but it will look to My Awesomest Theme for the CSS.

Inheriting the parent theme’s CSS

Say you want to use the parent’s CSS. Maybe you like 99% of it & you’re just going to override a few parts of it. Using the @import statement, you can import the parent theme’s styles and then add your own declarations below it. Browsers read CSS in a specific order (this is the Cascade part of Cascading Style Sheets) so it makes it easy to override specific styles while keeping the rest.

Below your comment block, add this line:
@import url(../twentyten/style.css);

Your child theme will now look just like Twenty Ten. All of Twenty Ten’s styles in style.css get imported to your theme. In Twenty Ten, this is the basic declaration for H1 through H6:

h1, h2, h3, h4, h5, h6 {
font-weight: normal;
clear: both;
}

In our child theme style.css, under the @import line, add this line:

h2 { font-weight:800;color:red;}

Save your changes and we’ve now made heading 2’s bold and red. Everything else stays according to Twenty Ten’s styles.

What about customizing template files?

What if you wanted to make structural changes to say, the header.php file? How would you do this in a child theme? It’s really simple. Copy the header.php file from the parent theme to your child theme’s directory and make your edits. WordPress will use your child theme’s header.php in place of the one in the parent theme.

That’s all there is to it.

Why use a child theme?

One very basic reason makes child themes beneficial: You can upgrade your parent theme without losing your design. A good child theme can persist through several WordPress upgrades. As a time-saver, this is pretty awesome. If you use Twenty Ten as a parent theme, there will be upgrades for Twenty Ten released. Version 1.1 just came out, in fact. Using a child theme on top of Twenty Ten, you in essence inherit those upgrades without having to redo your theme. Of course, the caveat exists that if you’re replacing template files, it’s on you to make sure your template files are up to date with released upgrades. That being the case, you’re still saving time and effort with a child theme as there are fewer files to go through than in a whole theme.

Another benefit of using child themes is for designers. Designers don’t have to build out a whole theme. They can create just a CSS file or a CSS file and the necessary templates.

Child themes present some serious advantages and they’re not that complicated to create. Give them a try.

To learn more about WordPress child themes go to:

  • WordPress Codex
  • WordPress Child Theme Basics
  • Child Themes 101 – Genesis Theme Framework

 

Filed Under: WordPress Tagged With: Austin WordPress Meetup, WordPress Theme, WordPress Tips & Tricks

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

About Sandi Batik

About Sandi Batik

Introverted Freelancer, WordPress trainer, consultant, curricula developer, author, unapologetic geek, unrepentant capitalist, lucky enough to do what I love … more about me about About Sandi Batik

  • Twitter

Search

Introverted Freelancer

Traits of Successful Introverted Freelancers

Traits of Successful Introverted Freelancers

2017 Business Check-up Workshop

2017 Business Check-up Workshop

Expanding Your Business With Automated Marketing Funnels

Expanding Your Business With Automated Marketing Funnels

How to Use Permission Marketing to Build Your WordPress Business

How to Use Permission Marketing to Build Your WordPress Business

How Much Should I Charge for Building or Designing a WordPress Website?

How Much Should I Charge for Building or Designing a WordPress Website?

Project Management

Keeping Scope Creep From Killing Your Schedule and Profit Margin

Keeping Scope Creep From Killing Your Schedule and Profit Margin

Project Management for WordPress Freelancers

Project Management for WordPress Freelancers

WordPress

Securing and Maintaining Your WordPress Site

Securing and Maintaining Your WordPress Site

How The WordPress Media Library Works — 2018

How The WordPress Media Library Works — 2018

How To Build an Information Structure for Your WordPress Site

How To Build an Information Structure for Your WordPress Site

How WordPress Themes Really Work

How WordPress Themes Really Work

How to Create and Manage eMail Newsletters from Your WordPress Site

How to Create and Manage eMail Newsletters from Your WordPress Site

How to Secure and Maintain Your WordPress Site

How to Secure and Maintain Your WordPress Site

Copyright © 2010-2023 Hands On WordPress · All Rights Reserved