I have a Wordpress installation in directory /blog.
I am trying to include multiple PHP files located in the root parent directory using relative paths such as "../../include/file.php".
Since Wordpress uses its install directory as the base, I tried to change it by including
<base href="http://mydomain.com" />
inside of the head, but it had no effect.
What can I do appropriately call these PHP files in my Wordpress theme?
you can try put this in wp-config
$rootpath = explode( basename( dirname(__FILE__) ), ABSPATH );
define( 'MYROOT', $rootpath[0] );
And then, for anyfile in the root directory :
include( MYROOT . 'somefile.php');
您可以在父目录中尝试此类文件破解:
$path = dirname( dirname( __FILE__ ) ) . '/some_file.php';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.