admin管理员组

文章数量:1122832

Per wordpress best practices, I created a child theme for an existing theme I have. Everything works fine until I try to add a template file which follows WP's template hierarchy conventions. For example, if I add category.php or archive.php, I get a white screen of death, and this is the error I get in Apache:

    [:error] [pid 2919] [client 98.24.106.38:64974] PHP Warning:  include(): 
Failed opening '/home/www-dev/beokinawa/wp-content/themes/x-child/index.php' for
 inclusion (include_path='.:/usr/share/php') in /home/www-dev/beokinawa/wp-
includes/template-loader.php on line 74, referer: 
.php?taxonomy=category

Whenever I try to view a category after uploading either of those files, the system wants to load the category edit screen url it seems. What could cause that? You can also see from the error that it's trying to find index.php, the last in the template hierarchy. If category.php or archive.php are present then there would be no reason for it to look for that file, right?

That the issue would be permissions is interesting. Here is a breakdown of permissions.

  • files are chown'ed user:www-root
  • per wordpress documentation, files are 664 ( even changed the directory and files to 777 briefly, but that didn't work either)

It seems I cannot add any additional files from the wordpress template hierarchy scheme. But, editing template parts is fine. The parent theme comes with wp-header.php, wp-footer.php, etc, and I can add those and overrides happen correctly.

Per wordpress best practices, I created a child theme for an existing theme I have. Everything works fine until I try to add a template file which follows WP's template hierarchy conventions. For example, if I add category.php or archive.php, I get a white screen of death, and this is the error I get in Apache:

    [:error] [pid 2919] [client 98.24.106.38:64974] PHP Warning:  include(): 
Failed opening '/home/www-dev/beokinawa/wp-content/themes/x-child/index.php' for
 inclusion (include_path='.:/usr/share/php') in /home/www-dev/beokinawa/wp-
includes/template-loader.php on line 74, referer: 
http://dev.bluepresley.com/beokinawa/wp-admin/edit-tags.php?taxonomy=category

Whenever I try to view a category after uploading either of those files, the system wants to load the category edit screen url it seems. What could cause that? You can also see from the error that it's trying to find index.php, the last in the template hierarchy. If category.php or archive.php are present then there would be no reason for it to look for that file, right?

That the issue would be permissions is interesting. Here is a breakdown of permissions.

  • files are chown'ed user:www-root
  • per wordpress documentation, files are 664 ( even changed the directory and files to 777 briefly, but that didn't work either)

It seems I cannot add any additional files from the wordpress template hierarchy scheme. But, editing template parts is fine. The parent theme comes with wp-header.php, wp-footer.php, etc, and I can add those and overrides happen correctly.

Share Improve this question edited Mar 16, 2017 at 12:47 user658182 asked Mar 15, 2017 at 20:19 user658182user658182 6152 gold badges14 silver badges34 bronze badges 2
  • that sounds like it can't find the file or maybe the permissions are wrong...did you confirm the file is there and set permissions? I like them to be 644 – rudtek Commented Mar 15, 2017 at 22:59
  • @rudtek thanks for the insight. I'm adjusting permissions now. I updated the post to reflect some of my settings. – user658182 Commented Mar 16, 2017 at 12:51
Add a comment  | 

1 Answer 1

Reset to default 0

Your initial idea is correct, WordPress shouldn't look for index.php if it finds category.php for a category archive. However, that may change if you don't have file permission and ownership set properly, or if FileSystem cache is messing with file_exists() check.

Follow these steps:

  1. Make sure your child theme files are readable by the web server user. Check both file permission and ownership.

  2. Check to see if the child theme is coupled properly with the parent theme and it can get templates from parent theme if any specific template is absent in the child theme.

  3. In wp-config.php use clearstatcache(); function (before require_once(ABSPATH . 'wp-settings.php');) to clear filesystem cache.

    In case you were adding & removing those files while testing and filesystem caching those files, clearstatcache(); will help you clearing those filesystem cache that may confuse WordPress core. Once done, remove clearstatcache(); call.

本文标签: Why would adding a template file to a child theme cause an error in templateloaderphp