5

I am trying to code in more consistent manner and would like to know what is the difference between WP: template_directory vs TEMPLATEPATH.

1 Answer 1

2

@tanktery

template_directory is the URL of the active theme's directory. Before version 2.6 of WordPress it was a local path.

TEMPLATEPATHis also the URL of the active theme's directory.

Before version 2.6 TEMPLATEPATH was used but now it is recommended to use <?php bloginfo('template_directory'); ?>.

Hope this helps!

3
  • I am using <?php include(TEMPLATEPATH . '/about.txt'); ?> How would I use <?php bloginfo('template_directory'); ?>?
    – tanktery
    Commented May 23, 2011 at 18:13
  • 2
    Actually, the correct functions to use are get_template_directory_uri() (for the URL to the template, i.e. Parent Theme, directory), and get_stylesheet_directory_uri() (for the URL to the Theme's directory). Commented May 23, 2011 at 19:33
  • <a href="<?php echo TEMPLATEPATH; ?>/about.txt">About</a> would be <a href="<?php bloginfo('template_directory'); ?>/about.txt">About</a> Commented May 24, 2011 at 1:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.