WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Difference between ABSPATH and TEMPLATEPATH? (4 posts)

  1. fatty123
    Member
    Posted 2 years ago #

    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?

  2. 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.)

  3. fatty123
    Member
    Posted 2 years ago #

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

    Let say the directory of my WP installation is:
    http://www.hello.com/wordpress/

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

  4. nosilver4u
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic