WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

For some reason I get the following output from

var_dump( plugin_dir_url( __FILE__ ) );


in a local install.

Note: I deactivated all plugins and added the line on top of the functions.php file of the default and unmodified TwentyEleven Theme

share|improve this question
Perhaps it's confused because the file isn't in the plug-ins directory? It probably finds the 'relative' path to it to append onto the plugin-url, in this case the 'relative' path is an absolute one, because it couldn't it in the directory (a dodgy fallback...?) – Stephen Harris Feb 10 '12 at 12:31
up vote 7 down vote accepted

There is plugin_basename() call some levels inside which seems to use WP_PLUGIN_DIR and WPMU_PLUGIN_DIR constants, so my guess would be this function is only meant to be used for things inside plugin directories and not other places like theme.

share|improve this answer
So the only chance left is to use get_stylesheet_directory_uri().'/path/to/some/file.ext;? – kaiser Feb 10 '12 at 12:48
@kaiser that would be my idea for use in theme. – Rarst Feb 10 '12 at 12:49
Rarst beat me to it - and I totally missed that @Kaiser was calling this from within a Theme. – Chip Bennett Feb 10 '12 at 12:51

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.