我想包括文件从插件到模板函数文件。这是我使用的代码:
$acf_url = plugins_url('/advanced-custom-fields/acf.php');
include_once($acf_url);但是这段代码不起作用,我得到了一个错误:
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那么密码有什么问题呢?
发布于 2018-06-14 13:37:47
这是因为您试图按URL包含一个目录,您需要调用路径,您可以使用常量WP_PLUGIN_DIR。将变量acf_url修改为以下内容将有效。
$acf_url = WP_PLUGIN_DIR . '/advanced-custom-fields/acf.php';https://wordpress.stackexchange.com/questions/306105
复制相似问题