【发布时间】:2020-04-11 12:28:36
【问题描述】:
我正在构建一个 WordPress 主题,并将用于自定义主题的函数分解到主题根目录中的 library 子目录中,并将它们包含在 include_once() 函数中。
我已将文件进一步分解为 library 内的子目录,并将每个文件都包含在正确的路径中。
我以这种方式包含近 20 个文件,没有任何问题,但我有一个文件,locations-post-type.php,位于 library/post-types 目录中,包含时会触发以下错误:
警告:include_once(library/post-types/locations-post-type.php):无法打开流:在 MY-THEME-PATH/wp-content/themes/caris/functions.php 中没有这样的文件或目录在第 98 行
警告:include_once(): 未能打开 'library/post-types/locations-post-type.php' 以包含 (include_path='.:/opt/alt/php70/usr/share/pear') 在 MY -THEME-PATH/wp-content/themes/caris/functions.php 第 98 行
/library/post-types 子目录中有 8 个文件,它们都具有相同的权限和所有权。运行ls -l 命令返回:
-rw-rw-r-- 1 rivalmi1 rivalmi1 5930 Jun 10 2019 careers-post-type.php
-rw-rw-r-- 1 rivalmi1 rivalmi1 5883 Jun 10 2019 events-post-type.php
-rw-rw-r-- 1 rivalmi1 rivalmi1 3066 Jun 10 2019 faqs-post-type.php
-rw-rw-r-- 1 rivalmi1 rivalmi1 3115 Jun 10 2019 history-post-type.php
-rw-rw-r-- 1 rivalmi1 rivalmi1 7181 Jun 10 2019 locations-post-type.php
-rw-rw-r-- 1 rivalmi1 rivalmi1 5121 Jun 10 2019 team-post-type.php
-rw-rw-r-- 1 rivalmi1 rivalmi1 3164 Jun 10 2019 testimonials-post-type.php
-rw-rw-r-- 1 rivalmi1 rivalmi1 6031 Jun 10 2019 workshops-post-type.php
我没有看到 locations-post-type.php 文件与我可以include_once() 没有错误的所有其他文件有任何区别。
另外,locations-post-type.php 在我的 XAMPP localhost 服务器上也可以正常工作,并且只会在我的登台服务器上导致错误。
有谁知道是什么导致了这个问题?
【问题讨论】:
标签: php wordpress apache wordpress-theming