我在我的服务器上的web服务目录中调用vanilla Wordpress函数时遇到了一些问题。在wordpress根目录以外的webservice中使用WordPress功能
我有这样的结构:
Root
- webservice
- - service.php
- wordpress
- - wordpress-root
我开始与谷歌这个问题,并找到这样一些解决方案...
require($_SERVER['DOCUMENT_ROOT'].'/wordpress-root/wp-load.php');
和
require($_SERVER['DOCUMENT_ROOT'].'/wordpress-root/wp-blog-header.php');
我加入这些行放到我的service.php中。 现在我的浏览器开始我重定向到以下URL并抛出一个错误 wp-admin/install.php
The requested URL /wp-admin/install.php was not found on this server.
难道有人有一个坚实的解决这个问题?
//编辑
调试后想通了,重定向是在function.php
/*
* Loop over the WP tables. If none exist, then scratch install is allowed.
* If one or more exist, suggest table repair since we got here because the
* options table could not be accessed.
*/
$wp_tables = $wpdb->tables();
foreach ($wp_tables as $table) {
// The existence of custom user tables shouldn't suggest an insane state or prevent a clean install.
if (defined('CUSTOM_USER_TABLE') && CUSTOM_USER_TABLE == $table)
continue;
if (defined('CUSTOM_USER_META_TABLE') && CUSTOM_USER_META_TABLE == $table)
continue;
// Error throw after this lines
if (! $wpdb->get_results("DESCRIBE $table;"))
continue;
因此,如果您导航到'/ WordPress的根/'会发生什么? – WheatBeak
@WheatBeak'require($ _ SERVER ['DOCUMENT_ROOT']。'/ wordpress-root /');'抛出一个错误“Warning:require”... – Pommesloch
您的WordPress安装必须是有效的,然后才能从另一个目录。 – WheatBeak