我正在使用子主题修改WordPress主题 . 在我的子主题文件夹中,我创建了一个名为“includes”的文件夹(就像父文件一样),并对content-post.php,content-single.php和content-single-portfolio.php文件进行了编辑 . 我已经添加到子文件夹中的functions.php文件中:
require_once( get_stylesheet_directory() . 'includes/content-post.php' );
require_once( get_stylesheet_directory() . 'includes/content-single.php' );
require_once( get_stylesheet_directory() . 'includes/content-single-portfolio.php' );
这会导致500内部错误,我不知道为什么 .
参考:http://codex.wordpress.org/Child_Themes
我也试过这个解决方案并得到相同的500错误:WordPress Child Theme including includes files
1 回答
您的代码可能转换为绝对URL
/home/user/public_html/wp-content/themes/my_themeincludes/content-single-portfolio.php
get_stylesheet_directory()应始终后跟正斜杠
require_once( get_stylesheet_directory() . '/includes/content-post.php' );
您最好的选择是检查错误日志,大多数500错误消息与PHP超时有关,特别是如果该网站以前在您进行任何PHP修改之前工作正常 .
您也可以尝试为每个文件逐个执行此类操作