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 I was building my website locally using WAMP, I was just using simple

include '/extras/file.php';

Of course, that would start at the root folder, and look in the extras folder. However, now I'm putting the website on a webserver, and have put it in a subdomain (to not interfere with the current live site).

So I tried to change the include tags to a few different variations:

include (home_url().'/extras/file.php');
include home_url().'/extras/file.php'; - (without parent brackets)

And also the two variations above, but using bloginfo(url), get_bloginfo(url) etc but still nothing seems to actually output anything.

Could it possible be becuase of the subdomain? If I alter the include statement, I can sometimes echo the home url as text, but that's not what I want.

Am I doing it right? or is there something obviously wrong?

share|improve this question
up vote 0 down vote accepted

The URL is the public web address. It is not related to the local file system. So what you need it a reference to the file system, not to the URL.

// path in relation to document root
include $_SERVER['DOCUMENT_ROOT'] . '/extras/file.php';


// path in relation to current position
include dirname( __FILE__ ) . '/extras/file.php';
share|improve this answer
Thanks, that has worked (I used the first option). But my question is, when I move the site out of the subdomain and onto the main domain, will this need adjusting at all? – Lee Feb 12 '14 at 11:56
Yes, it should. The question is where you need that include. There are specialized helper functions for plugins and themes for that. You should use these when ever possible. – toscho Feb 12 '14 at 11:58

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.