Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
    
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 at 19:09

1 Answer 1

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.

share|improve this answer
    
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 at 18:39

Your Answer

 
discard

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.