Search code examples
phpwordpressrequiremybb

Relative path on php


I'm using a free hosting, I installed wordpress and mybb and I'm integrating both , so in the public_html I got the wp stuff and the forum directory, I'm making a template for wordpress so I need to use the directory /public_html/wp-content/themes/thetheme/somepage.php and require que file global.php in the /public_html/forum directory, I'm using this:

require_once '../../../foro/global.php';

For some reason It don't work, some help here?


Solution

  • Using relative paths can cause some issues, you may be able to solve this by finding the absolute path. You can find the absolute path of a particular file using the getcwd() function in PHP. Then simple just use require_once with a slash in front to get directly to the directory in question.