Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

migrated from stackoverflow.com May 23 '11 at 16:01

This question came from our site for professional and enthusiast programmers.

add comment

1 Answer

up vote 2 down vote accepted

@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!

share|improve this answer
    
I am using <?php include(TEMPLATEPATH . '/about.txt'); ?> How would I use <?php bloginfo('template_directory'); ?>? –  tanktery May 23 '11 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). –  Chip Bennett May 23 '11 at 19:33
    
<a href="<?php echo TEMPLATEPATH; ?>/about.txt">About</a> would be <a href="<?php bloginfo('template_directory'); ?>/about.txt">About</a> –  cchiera May 24 '11 at 1:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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