0

I want to include file from a plugin to templates function file. This is the code i use :

$acf_url = plugins_url('/advanced-custom-fields/acf.php');
include_once($acf_url);

But this code is not working and i'm getting this error :

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

So what is the codes problem ?

2

This is because you are trying to include a directory by URL, you need to call path, you can use the constant WP_PLUGIN_DIR. Modifying the variable acf_url to the following would work.

$acf_url = WP_PLUGIN_DIR . '/advanced-custom-fields/acf.php';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.