开发者

require wp-load.php 3 directories back

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...


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.


Here is a semi-automated way to do this:

$incPath = str_replace("/wp-content/plugins/PLUGIN_NAME","",getcwd());
ini_set('include_path', $incPath);
include('wp-load.php');

Regardless though, it's still a bad idea to include wp-load.php. ( if this link is ever deleted, See that page here )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜