Search code examples
phpwordpressfunctionrequire-once

require_once localhost wordpress in functions error


Have tried most suggested answers on this topic and none seem to work for me.

I have a wordpress installed on my localhost using MAMP, now in my functions.php I am attempting the following code:

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

I get this error:

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

Thanks


Solution

  • Set the current path to a variable first, then set the path relative to that.

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