首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不能将文件从插件包含到主题中

不能将文件从插件包含到主题中
EN

WordPress Development用户
提问于 2018-06-14 13:15:24
回答 1查看 473关注 0票数 0

我想包括文件从插件到模板函数文件。这是我使用的代码:

代码语言:javascript
复制
$acf_url = plugins_url('/advanced-custom-fields/acf.php');
include_once($acf_url);

但是这段代码不起作用,我得到了一个错误:

代码语言:javascript
复制
Warning: include_once(http://localhost/wp-content/plugins/advanced-custom-fields/acf.php): failed to open stream: HTTP request failed! HTTP/1.0 500 Internal Server Error in G:\MAMP\htdocs\wp-content\themes\mytheme\functions.php on line 3
Warning: include_once(): Failed opening 'http://localhost/wp-content/plugins/advanced-custom-fields/acf.php' for inclusion (include_path='.;C:\php\pear') in G:\MAMP\htdocs\wp-content\themes\mytheme\functions.php on line 3

那么密码有什么问题呢?

EN

回答 1

WordPress Development用户

回答已采纳

发布于 2018-06-14 13:37:47

这是因为您试图按URL包含一个目录,您需要调用路径,您可以使用常量WP_PLUGIN_DIR。将变量acf_url修改为以下内容将有效。

代码语言:javascript
复制
$acf_url = WP_PLUGIN_DIR . '/advanced-custom-fields/acf.php';
票数 2
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/306105

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档