Codex Child Theme Page

Including code in WordPress Child Themes

A project of even moderate size easily builds up quite a few items in it’s functions.php file. Even when working on a child theme I find that it’s not uncommon to need to add a custom admin panel or a custom post type. There is another gotcha in child themes though.

Typical code samples that talk about organizing files for WordPress will show you something like this.

require_once( TEMPLATEPATH . ‘/path/to/file.php’ );

That works perfectly fine for a regular WordPress them but in a child them it’s pointing at the parent theme. To fix/get around this all you need it a simple modification of which constant you use to:

require_once( STYLESHEETPATH . ‘/path/to/file.php’ );

This is not the first time I’ve written about an include gotcha with Child Themes in WordPress so go read the other article if this isn’t quite what you’re looking for.

To get a head start, join thousands of other men and Stop The Struggle.

Get my free eBook to help you stop working all the hours without traction.

You’ll also get a weekly email with good resources to help you do family with the same intention you do your work. Both need to run well if you want to win.

%d bloggers like this: