【发布时间】:2020-01-28 15:54:36
【问题描述】:
我将我的网站从本地主机移到 live 并且“需要一次”似乎已损坏。
require_once():打开失败需要'wp-content/themes/my-theme/layout/twitterAPI.php'(include_path='.:/opt/cpanel/ea-php71/root/usr/share/pear' )
我试过了:
require_once $_SERVER['DOCUMENT_ROOT'].'/demo/wp-content/themes/my-theme/layout/twitterAPI.php';
require_once(get_template_directory().'/layout/twitterAPI.php');
include( get_template_directory() . '/layout/twitterAPI.php' );
require_once('twitterAPI.php');
【问题讨论】:
-
您是否在演示文件夹中上传了网站?
-
您确定该文件存在吗?
-
是的,文件在正确的文件夹中。
-
试试
require_once __DIR__ . '/relative-path-from-this-file/layout/twitterAPI.php';看看是否有帮助。我怀疑require_once被破坏了,因为 WP 在内部使用它......很多。它会在涉及您的代码之前抛出错误。 -
您使用的是子主题吗?您可以使用 get_stylesheet_directory() 函数作为子主题目录路径。