我想在 OpenCart 标题中显示一个 Wordpress 菜单。在我的 test.php 页面中,我添加了以下代码;
<?php
require($_SERVER['DOCUMENT_ROOT'].'/wordpress/wp-load.php');
wp_nav_menu( array( 'menu' => 'Test' ) ); ?>
而且效果很好,但是当我将其添加到 OpenCart 的 header.tpl 模板中时,我收到一个错误;
Fatal error: Call to a member function get_queried_object() on a non-object in /....../wordpress/wp-includes/nav-menu-template.php on line 256
你能帮忙吗?你以前做过吗?似乎是 OpenCart 导致了问题?
以下是关于进展的附加更新
好的,我已经运行了 OC 和 WP 的默认安装。
Wordpress 位于根目录中 - www.test.local Opencart 位于根目录/存储目录中 - www.test.local/store/
在 Opencart Default Tenplate Header 中,我有以下代码:
<?php $path = $_SERVER['DOCUMENT_ROOT'].'/wp-load.php';
echo $path;
require_once($path);
wp_nav_menu( array( 'menu' => 'Test' ) ); ?>
这会产生以下错误:
test.local/Sites/test.local/htdocs/wp-load.phpNotice: Constant DB_PASSWORD already defined in test.local/Sites/test.local/htdocs/wp-config.php on line 25Unknown: Redefining already defined constructor for class WP_Widget in test.local/Sites/test.local/htdocs/wp-includes/widgets.php on line 93Warning: strpos() expects parameter 1 to be string, array given in test.local/Sites/test.local/htdocs/wp-includes/functions.php on line 3048
Fatal error: Call to a member function get_queried_object() on a non-object in test.local/Sites/test.local/htdocs/wp-includes/nav-menu-template.php on line 256
有趣的是,当我从 Wordpress 中删除“测试”菜单时,菜单显示在 Opencart 中,但是我仍然看到以下错误:
/Sites/test.local/htdocs/wp-load.phpNotice: Constant DB_PASSWORD already defined in /Sites/test.local/htdocs/wp-config.php on line 25Unknown: Redefining already defined constructor for class WP_Widget in /Sites/test.local/htdocs/wp-includes/widgets.php on line 93Warning: strpos() expects parameter 1 to be string, array given in /Sites/test.local/htdocs/wp-includes/functions.php on line 3048Notice: Trying to get property of non-object in /Sites/test.local/htdocs/wp-includes/post-template.php on line 845
线索?有人有什么想法吗?