• Resolved Steven

    (@stgoos)


    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: https://localhost/wp-content/themes/K2

    I actually need something like https://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…

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Steven

    (@stgoos)

    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 ??

    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…

    get_template_uri() doesn’t seem to exist. get_template_directory_uri() is fine.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get child theme directory path’ is closed to new replies.