[wp-testers] template_directory broken when using child themes

Krusty Ruffle krustyruffle at rustykruffle.com
Sat Nov 1 00:09:29 GMT 2008


You can use the following functions to get directory or uri information.
Template functions give you the directory of the parent theme, while
stylesheet functions will give you the child themes directory. Functions
that end with uri give you the uri to the directory, without a trailing
slash the others return the full directory path to the directory, also
without the trailing slash. These also do not echo the results so they need
to be echoed or stored in a variable or whatever. I don't know if there are
equivalent functions that echo the results, but I have checked these on 2.7
from cvs. You can look in the source code of wp
-includes/theme.php to see these and some other usefull functions...

get_stylesheet_directory_uri()
get_stylesheet_directory()
get_template_directory()
get_template_directory_uri()

Hope this helps, and have fun :)

On Fri, Oct 31, 2008 at 10:20 AM, Ben Huson <ben at thewhiteroom.net> wrote:

> Just did a quick test in a child theme in 2.7:
>
> - bloginfo('template_directory') points to the dependant theme directory
> - bloginfo('stylesheet_directory') points to the child theme directory
>
> The stylesheet_directory is supposed to be depreciated from version
> 2.3.1 but child themes would seem to be a case in point where you
> might want to reference either the child theme directory or the
> dependant theme directory.
>
> See http://wordpress.org/support/topic/188569
>
> If the template_directory is set to point to the child theme, how can
> you refer to the parent theme?
>
> Maybe stylesheet_directory should not have been depreciated?
>
> - Ben
>


More information about the wp-testers mailing list