[theme-reviewers] Child themes discussion

Otto otto at ottodestruct.com
Sat Jan 22 18:15:00 UTC 2011


On Sat, Jan 22, 2011 at 12:12 PM, Chip Bennett <chip at chipbennett.net> wrote:
> So, are we saying that for Themes that are *intended* to be Child-Theme
> ready, they must use get_template_, rather than get_stylesheet_, in all
> instances?

Nothing is ever that simple. :)

Stylesheet functions always return the path to the active theme.

Template functions *can* return the path to the parent theme, if you
have a parent.

Generally speaking, it's a bad idea to use either one except in
specialized contexts.

To get and include a PHP file, for example, the safest way is
get_template_part('file'). This does the proper searching for the file
in the child and the parent (along with handling the special file-name
/ file fallback cases for get_template_part('file','name').

You *can* use locate_template to just get the local path of a file in
the child/parent. A simple locate_template('file.png') would do the
trick. It only tries to load the file as php for the case of the
second parameter being true. This doesn't help if you need a URL.

I don't know of a good way to allow image/css file overrides in a
child, since you need the URL of them. Maybe somebody else can
enlighten me?

-Otto


More information about the theme-reviewers mailing list