无法动态访问 wp-load.php [英] Cant access wp-load.php dynamically
本文介绍了无法动态访问 wp-load.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何访问 wp-load.php ?
How to have access to wp-load.php ?
我可以使用以下方式访问它
I can access it using the following
require_once("../../../../wp-load.php");
但我需要动态找到它,所以我使用了以下但它们都不起作用.
But I need to find it dynamically so I am using the following but none of them works.
require_once( dirname(__FILE__).'/../../../wp-load.php');
require_once( dirname(__FILE__)."/../../../wp-load.php");
require_once( ABSPATH.'wp-load.php');
require_once( ABSPATH."wp-load.php");
如何访问 localhost:8888/wordpress/wp-load.php?
How to have access to localhost:8888/wordpress/wp-load.php?
推荐答案
在需要加载 wp-load.php 的文件开头添加以下代码片段
Add below code snippets at beginning of file where you require to load wp-load.php
/* FindWPConfig - searching for a root of wp */
function FindWPConfig($dirrectory){
global $confroot;
foreach(glob($dirrectory."/*") as $f){
if (basename($f) == 'wp-config.php' ){
$confroot = str_replace("\\", "/", dirname($f));
return true;
}
if (is_dir($f)){
$newdir = dirname(dirname($f));
}
}
if (isset($newdir) && $newdir != $dirrectory){
if (FindWPConfig($newdir)){
return false;
}
}
return false;
}
if (!isset($table_prefix)){
global $confroot;
FindWPConfig(dirname(dirname(__FILE__)));
include_once $confroot."/wp-config.php";
include_once $confroot."/wp-load.php";
}
这篇关于无法动态访问 wp-load.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文