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)
Samuel said
The link is broken :(
Samuel said
Here’s the correct link. It seems that dont like direct access to the generated url (after click on this).
Leonid Mamchenkov said
Samuel,
thanks for letting me know. I’ve fixed the link in the post. It was a copy-pasto. :)
Buenos Aires Me Duele said
Thanks for the tip
davidrpotter said
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.
Leonid Mamchenkov said
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.
What Makes WordPress Tick? - Untwisted Vortex said
[…] 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 […]
MySpace Addons said
Thanks – i’ve never experimented with changing constants yet. /me enjoys post.
Nick Georgakis said
Thanks for the tip, some constants are a popular target for malicious hacker bots/scripts!
blackmoon said
thanks for your tips
Michel said
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 :(
Useful WordPress Resources | Bui4Ever | Bui4Ever.com said
[…] WordPress Constants […]