函数中的require_once localhost wordpress错误

时间:2015-12-14 13:13:27

标签: php wordpress function require-once

在这个主题上尝试了大多数建议的答案,似乎没有一个对我有用。

我使用MAMP在我的localhost上安装了wordpress,现在在我的functions.php中我正在尝试以下代码:

require_once('framework/functions/core-functions.php' );

我收到此错误:

Warning: require_once(framework/functions/core-functions.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/wordpress/wp-content/themes/mytheme/functions.php on line 443

Fatal error: require_once(): Failed opening required 'framework/functions/core-functions.php' (include_path='.:/Applications/MAMP/bin/php/php5.6.10/lib/php') in /Applications/MAMP/htdocs/wordpress/wp-content/themes/mytheme/functions.php on line 443

由于

1 个答案:

答案 0 :(得分:0)

首先将当前路径设置为变量,然后设置相对于该变量的路径。

$path = realpath(dirname(__FILE__));
require "$path/framework/functions/core-functions.php";