WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any equivalent to functions like plugins_url() and content_url() that give you either the relative paths or the file path.

For instance, instead of


I want:


I know that I can build this path using the ABSPATH constant, but I'm specifically interested in learning if there are built in functions to handle this.

In the meantime, I'll probably just write a function to swap the url for the abspath.

EDIT: Here's the simple function that I wrote to handle this:

function get_file_path($url)
    return str_replace(site_url(), ABSPATH, $url);

Seems to do the trick, but I'd much rather use built in functions if available.

share|improve this question
up vote 1 down vote accepted

There aren't any for plugins, but you can (and should) use WP_CONTENT_DIR, instead of ABSPATH.

For themes you have locate_template().

share|improve this answer
Thanks scribu! Funny thing is the project I was working with attempted to redefined WP_CONTENT_DIR. – tollmanz Aug 4 '11 at 19:50
As per my answer there is WP_PLUGIN_DIR, plugins are not strictly tied to content. Gave me a lot of grief recently. :) – Rarst Aug 4 '11 at 20:04
@Rarst After Scribu's answer, I looked around where WP_CONTENT_DIR was defined and found WP_PLUGIN_DIR. Nice to know these exist. I've ridded the project of ABSPATH! – tollmanz Aug 4 '11 at 20:30

There is plugin_dir_path(), but it's not exact analogue of plugins_url().

Also ABSPATH is unreliable for how you use it, related paths can be easily redefined. See default-constants.php file.

Namely there are:

share|improve this answer
Thanks as always Rarst! – tollmanz Aug 4 '11 at 20:31

Your Answer


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.