views:

118

answers:

1

I'm trying to include a file (/wp-load.php) at the beginning of the /html/ directory. I'm trying to include it from /wp-content/themes/pw-steel-orange/index-load.php, but I always get the error message

Warning: require_once(../wp-load.php) [function.require-once]: failed to open stream: No such file or directory in /nfs/c07/h01/mnt/102799/domains/platyworld.com/html/wp-content/themes/pw-steel-orange/index-load.php on line 1

Fatal error: require_once() [function.require]: Failed opening required '../wp-load.php' (include_path='.:/usr/local/php-5.2.6-1/share/pear') in /nfs/c07/h01/mnt/102799/domains/platyworld.com/html/wp-content/themes/pw-steel-orange/index-load.php on line 1

Am I doing something wrong? I though ../ brings the includes to the beginning directory

Sorry if this is a duplicate, I couldn't find something related to this in my searches...

A: 

You can issue the following command to see where you are pulling the file from (where you are at):

// get your current working directory
echo getcwd();

Then include the file accordingly.

// file is 3 dirs back
include '../../../wp-load.php';

If you are using a framework like CodeIgniter, for instance, there will be an index.php file at the very start of your application that will be calling all other code. So you would have to include that file according to that file.

Most frameworks use something they call a BASEPATH that is the current actual full server path to the site. This may prove very useful when migrating your site to another destination.

Frankie
weird... I tried the ../../../wp-load.php a few times and it didn't work until now... thanks!
sman591
@sman591 the 3 levels back was a wild guess... ! :) I was just trying to let you know how to see where you are at with `getcwd` and then adjusting accordingly. But I'm glad it worked! ;)
Frankie