Support » Themes and Templates » TEMPLATEPATH vs get_template_directory(): What is the difference?

  • 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');

    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?

Viewing 1 replies (of 1 total)
  • 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.

Viewing 1 replies (of 1 total)
  • The topic ‘TEMPLATEPATH vs get_template_directory(): What is the difference?’ is closed to new replies.