Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress How to Make a Website with WordPress Customizing WordPress Themes How to Make Child Themes

Unclear on child/parent theme relationship

Hi,

What am I missing here? Are we just copying the original style.css or whatever php files over and then overriding the code in the child theme? Im just a bit confused how the child theme is referencing the parent updates but still maintaining your style or php changes.

Thank you

Hanifah

2 Answers

You actually create a new style.css file and import the original style.css into it instead of outright copying it. The way the child theme references the parent is by using meta data in the form of a comment at the top of the style.css file. Example from wp codex:

/*
 Theme Name:   Twenty Fourteen Child
 Theme URI:    http://example.com/twenty-fourteen-child/
 Description:  Twenty Fourteen Child Theme
 Author:       John Doe
 Author URI:   http://example.com
 Template:     twentyfourteen
 Version:      1.0.0
 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
 Text Domain:  twenty-fourteen-child
*/

@import url("../twentyfourteen/style.css");

/* =Theme customization starts here
-------------------------------------------------------------- */

Now if you added more files into the child theme, such as page.php or functions.php, they would override the files of the same name in the parent theme.

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hi,

You only copy over the files from the parent theme you want to override.