WordPress.org

Ready to get started?Download WordPress

Forums

TEMPLATEPATH vs get_template_directory(): What is the difference? (2 posts)

  1. shamu1001
    Member
    Posted 1 year ago #

    I'm trying to figure out the difference between these. TEMPLATEPATH doesn't have its own Codex page, as far as I can tell, but I did find a mention of it on the load_theme_textdomain() page. The page has a very peculiar set of examples, one using TEMPLATEPATH and the other using get_template_directory().

    Ex 1: get_template_directory()
    load_theme_textdomain('my_theme', get_template_directory() . '/languages');

    Ex 2: TEMPLATEPATH
    load_theme_textdomain( 'my_theme', TEMPLATEPATH . '/languages' );

    So... if two calls return the same path, what is the difference? I've read a couple posts from Google hinting at a possible connection to child theme/main theme relationships. Should I use one in main themes and another in child themes? What are the best practices?

  2. Chandan Kumar
    Member
    Posted 1 year ago #

    TEMPLATEPATH is just refers to a constant defined by WordPress and if child themes are created for your theme and utilizing TEMPLATEPATH is not guaranteed to find the right directory location if variables are set otherwise while the initiation of wordpress is executed.

    We usually use get_template_directory or get_stylesheet_directory function to get the themes directory url.

Topic Closed

This topic has been closed to new replies.

About this Topic