当我加载Wordpress网站时出现此错误:
警告: include_once(../../插件/ ACF-位置场主/ ACF-location.php) [function.include-once]:失败了 open stream:没有这样的文件或目录 C:\ WAMP \ WWW \ cmpmushrooms.tld \可湿性粉剂内容\主题\ shrooms_v0.1 \的functions.php 在第455行
它所指的代码是:
function my_register_fields()
{
include_once('../../plugins/acf-location-field-master/acf-location.php');
}
我意识到它说它无法找到文件,但为什么呢?因为它存在于目录中。
答案 0 :(得分:1)
你应该这样做以包含来自WP插件目录的文件:
include( plugin_dir_path( __FILE__ ) . 'plugin-name/file-name.php');
如果要包含该目录中的所有文件,请按以下方式使用:
foreach ( glob( plugin_dir_path( __FILE__ )."plugin-name/*.php" ) as $file )
include_once $file;
玩得开心:)
答案 1 :(得分:0)
为什么不:
include_once ( WP_PLUGIN_DIR . '/acf-location-field-master/acf-location.php');