WordPress主题中的PHP”警告include_once():无法打开流”

我正在构建一个WordPress主题, 并使用了一些分解功能, 这些功能可用于自定义主题到主题根目录中的库子目录中, 并将它们包含在include_once()函数中。

我进一步将文件分解为库内的子目录, 并包括每个具有正确路径的文件。

我以这种方式包括了将近20个文件, 没有任何问题, 但是在library / post-types目录中有一个文件locations-post-type.php, 如果包含该文件, 则会触发以下错误:

警告:include_once(library / post-types / locations-post-type.php):无法打开流:第98行的MY-THEME-PATH / wp-content / themes / caris / functions.php中没有此类文件或目录警告:include_once():无法在MY-THEME-中打开” library / post-types / locations-post-type.php”以包含在内(include_path =’。:/ opt / alt / php70 / usr / share / pear’)第98行的PATH / wp-content / themes / caris / functions.php

/ 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服务器上也能正常工作, 并且只会在我的登台服务器上导致错误。

有谁知道是什么引起了这个问题?


#1


尝试使用get_template_directory()(或将get_stylesheet_directory()用于子主题)以确保你需要从所需位置获取文件。

require_once( trailingslashit( get_template_directory() ) . 'library/post-types/locations-post-type.php' );

来源:

https://www.srcmini02.com/63769.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37574.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?