I've come across a number of ways to call the WP "root" folder

But what if I want to include a php file that is in a parent folder of WP?

Example http://www.site.com/, where the WP blog is in http://www.site.com/blog/

So far I can't find anything on this topic, and including the absolute URL to the file isn't working

  • This is php question rather than a WordPress one, but you include a file not by its url but by its location on the server, probably something like /home/youraccountname/public_html/yourfile.php – Andrew Bartel Feb 27 '14 at 19:09

OK. I'm assuming you have Wordpress setup as a sub-directory of your root URL. If so, this should work:

<?php include 'http://www.site.com/file.php'; ?>

Sometimes people write the include special form with parentheses. In most cases it won't break anything, but if your code looks like this, try removing them:

<?php include('http://www.site.com/file.php'); ?>

Also, make sure that the "Wordpress Address" and "Site Address" are both set to the proper URL in the admin settings. This might throw off your absolute URL.

  • Thanks, doesn't seem to be working, but it didn't break the page either. For now I have a separate include file in the WP root that is working – Drewdavid Mar 6 '14 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.