根据找到的示例here 还有其他一些,我试图从特定URL加载非wordpress页面,同时访问wordpress核心。
我有以下代码(看起来像预期的那样工作)连接到template_redirect
措施:
function templateRedirect() {
global $wp;
if ( $wp->query_vars[\'pagename\'] == \'nlm-admin-thumbnail\' ) {
global $wp_query;
// if we have a 404 status
if ($wp_query->is_404) {
// set status of 404 to false
$wp_query->is_404 = false;
$wp_query->is_archive = true;
}
// change the header to 200 OK
header("HTTP/1.1 200 OK");
//load our template
include( dirname( __FILE__ ) . \'/thumbnail.php\' );
exit;
}
}
add_action(\'template_redirect\', \'templateRedirect\');
我的问题是在中执行代码时thumbnail.php
. 这个文件应该下载网页的缩略图并输出原始图像。nlm admin缩略图slug用作图像标记的src。当我执行缩略图时。php我一直在获取undefined function some_wp_function()
. 我已经包括了http。php和类http。wp includes文件夹中的php。现在我已经包括了这些,下一个错误是undefined function apply_filters()
.
以这种方式加载php文件是否不允许我访问wp核心,并且应该应用\\u filers()不可访问?