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

When including files in a plugin, I've seen people do


and yet WordPress wp_enqueue_script/style uses URI for the file path (such as plugins_url).

What difference is there? I'm confused...

share|improve this question
up vote 2 down vote accepted

When you include something, you use the file path because it's a local file and you're reading into the environment right here and now and using that code.

When you "enqueue" something, you're not reading the file in, you're sending the URL of the file to a system that puts that URL in the resulting output webpage, for the viewer's browser to then load and read.

You use a file path when the PHP code is manipulating the file. You use a URL when the browser needs to see that URL and retrieve the file itself.

share|improve this answer
Are you saying that there are 2 versions of the same file (say style.css)? What if I have my style.css installed locally? Why do I need to use the URI then? – Bobby Dec 1 '13 at 1:54
For example, echo get_theme_root().'twentythirteen/style.css' VS echo get_stylesheet_uri(). Are they both linking to the same file? – Bobby Dec 1 '13 at 2:06
Your question does not make any sense. get_theme_root() gives a local path, while get_stylesheet_uri() gives a URL. They connect to the same file, but in two different ways. – Otto Dec 2 '13 at 5:29

Dir[ectory] refers to paths in local server file system. These must be used for accessing/manipulating files inside the program and are not (and should not) be used or visible to visitors on web page.

URL/URI refers to web-accessible paths as served by web server to visitors.

PS while technically PHP can include/require files from URLs as well it's insecure, poorly performing and shouldn't be used.

share|improve this answer

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.