FacetWP / use-child-theme

A WordPress class to ensure that a child theme is installed and active
65 stars 21 forks source link

Loading files within a theme #6

Closed emiluzelac closed 8 years ago

emiluzelac commented 8 years ago

This isn't a recommended usage:

include( dirname( __FILE__ ) . '/use-child-theme.php' );

Option A: include get_template_directory() . '/use-child-theme.php';

Option B: require get_template_directory() . '/use-child-theme.php';

justintadlock commented 8 years ago

I'd actually recommend the following for theme usage:

require_once( trailingslashit( get_template_directory() ) . 'use-child-theme.php' );

And, this for plugin usage:

require_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'use-child-theme.php' );
emiluzelac commented 8 years ago

trailingslashit is a personal preference ;) But yeah, that works too!

mgibbs189 commented 8 years ago

Thanks guys, README.md updated