WordPress Bits

Hacking WordPress. Keeping the bits together.

Tip #7 : WordPress constants

Posted by Leonid Mamchenkov on October 5, 2007

ABSPATH is one of the most known WordPress constants. It holds filesystem path to WordPress installation and is often used to construct filesystem paths relative to WordPress. But what other constants are there in WordPress? The answer is easy to get than it might seem. You can see a full list here.

(Thanks to Benedict Eastaugh over at wp-hackers mailing list for the above link)

11 Responses to “Tip #7 : WordPress constants”

  1. Samuel Says:

    The link is broken :(

  2. Samuel Says:

    Here’s the correct link. It seems that dont like direct access to the generated url (after click on this).

  3. Leonid Mamchenkov Says:

    Samuel,

    thanks for letting me know. I’ve fixed the link in the post. It was a copy-pasto. :)

  4. Buenos Aires Me Duele Says:

    Thanks for the tip

  5. davidrpotter Says:

    Good reference. It would be nice to see some info on what the constants are used for (e.g. definition, purpose), but this is a good start.

  6. Leonid Mamchenkov Says:

    davidrpotter,

    constants hold a value which cannot be changed during the execution of the script. Sometimes these values come handy. When writing plugins for example. Like with ABSPATH example above. Instead of trying to figure out in which directory WordPress is installed, just use the value in ABSPATH.

  7. What Makes WordPress Tick? - Untwisted Vortex Says:

    [...] Bits is such a blog. A recent article, Tip #7 : WordPress constants, showed up on my WordPress dashboard and I just had to take a look. While the article points to a [...]

  8. MySpace Addons Says:

    Thanks - i’ve never experimented with changing constants yet. /me enjoys post.

  9. Nick Georgakis Says:

    Thanks for the tip, some constants are a popular target for malicious hacker bots/scripts!

  10. blackmoon Says:

    thanks for your tips

  11. Michel Says:

    Sometimes ABSPATH is your enemy, for example, when you want to go ONE DIRECTORY UP from WordPress;-)

    I had this problem with file uploads, because my upload dir is one level up from my WordPress install dirs… Still didn’t resolve it :(

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>