stgoos
Member
Posted 2 months ago #
Hi all,
I'm creating a child theme for K2 and I wonder how I can get the child theme path. Does anyone know this?
Currently, this build in function comes closest to what I need:
bloginfo('template_directory')
Results in: http://localhost/wp-content/themes/K2
I actually need something like http://localhost/wp-content/themes/ChildThemeName
I need it to refer to an image folder in the child theme and I want to be flexible in how I name the child theme so a simple replace of K2 in ChildThemeName is not the wanted option...
stgoos
Member
Posted 2 months ago #
Continued to play around with some other thoughts and I came up with this solutions which works fine:
dirname( get_bloginfo('stylesheet_url') )
I actually have added this as a constant (template_child_directory) to the header file of the child theme so I can use it anywhere within the child theme :)
netweblogic
Member
Posted 1 month ago #
It's not explained anywhere (just edited the function reference now to reflect this) but as you've discovered, the stylesheet directory is what points you to the child theme. So, for child themes you want these functions:
get_stylesheet()
get_stylesheet_uri() etc.
and for parent themes you will get the locations with:
get_template()
get_template_uri() etc.
Good stuff. Thanks.
I put:
define('child_template_directory', dirname( get_bloginfo('stylesheet_url')) );
in a my child theme functions.php. Seems to make sense there...
andymacb
Member
Posted 1 week ago #
get_template_uri() doesn't seem to exist. get_template_directory_uri() is fine.