Support » Themes and Templates » Difference between ABSPATH and TEMPLATEPATH?

  • Resolved fatty123


    What is the difference? Is it part of wordpress codex or can be use in normal php?

    Can’t I just use bloginfo(‘wpurl’); instead?

Viewing 3 replies - 1 through 3 (of 3 total)
  • ABSPATH refers to the directory in which WP is installed. TEMPLATEPATH refers to the current theme directory, or the parent theme directory if you’re currently using a child theme. Both are WP constants, so are not available in PHP outside WP.

    As for bloginfo('wpurl'), it’s not the same as either one of them; it echoes a URL rather than a file path. (And anyway, if that’s what you’re actually trying to do, you should be using site_url() instead.)

    Thanks for the explanation between ABSPATH and TEMPLATEPATH, but now I have another question…

    Let say the directory of my WP installation is:

    what differences will it makes if I use,
    include_once(ABSPATH . ‘wp-content/themes/posttypes.php’);
    include_once($url = site_url(‘/wp-content/themes/posttypes.php’, ‘https’); echo $url;);

    The difference, as Amy pointed out, is that the first one is a file path, and the second one is a URL. The result is that the first option will work, and the second will most definitely fail.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Difference between ABSPATH and TEMPLATEPATH?’ is closed to new replies.