admin管理员组

文章数量:1127085

My WordPress site uses the following:

  • Header.php file from the theme.
  • Footer.php file from the theme.
  • Apart from the Posts Page, the rest of the site makes use of Gutenberg blocks (not header or footer area).
  • The posts page uses the site's index.php file at wp-content/themes/meow/index.php

When I updated the site to 5.9, the posts page no longer looked the same. I checked what file loads when the posts page is viewed in the browser:

  1. Before the update to 5.9, the site loads: wp-content/themes/meow/index.php.
  2. After the update, the site loads: wp-includes/template-canvas.php

I thought WordPress was supposed to be future-proof. How can I make use of index.php, instead of template-canvas.php, when the site is updated to 5.9?

My WordPress site uses the following:

  • Header.php file from the theme.
  • Footer.php file from the theme.
  • Apart from the Posts Page, the rest of the site makes use of Gutenberg blocks (not header or footer area).
  • The posts page uses the site's index.php file at wp-content/themes/meow/index.php

When I updated the site to 5.9, the posts page no longer looked the same. I checked what file loads when the posts page is viewed in the browser:

  1. Before the update to 5.9, the site loads: wp-content/themes/meow/index.php.
  2. After the update, the site loads: wp-includes/template-canvas.php

I thought WordPress was supposed to be future-proof. How can I make use of index.php, instead of template-canvas.php, when the site is updated to 5.9?

Share Improve this question edited Feb 22, 2022 at 19:46 Denby101 asked Feb 22, 2022 at 19:32 Denby101Denby101 1011 bronze badge 3
  • Are you using a child theme? – Sally CJ Commented Feb 22, 2022 at 23:25
  • @SallyCJ I'm not using a child theme. – Denby101 Commented Feb 23, 2022 at 17:09
  • 1 Is it a custom theme you developed on your own? And, "the posts page no longer looked the same" - you mean the single post pages like example.com/hello-world only (i.e. other pages like category archives and search results pages are not using the template-canvas.php)? Also, "I checked what file loads" - how did you check? Try adding a dummy text (e.g. test123) to the index.php file and see if the text is showing on the single post pages? – Sally CJ Commented Feb 24, 2022 at 2:13
Add a comment  | 

2 Answers 2

Reset to default 1

Thank you for the solution, but this one is better than hacking the core files you can use this code in your functions.php to disable block theme support

function action_remove_block_templates()
{
    remove_theme_support('block-templates');
}
add_action('after_setup_theme', 'action_remove_block_templates', 15);

this happens because wp_enable_block_templates() is enabled. Try to navigate to wp-includes/theme-templates.php and comment that function, its placed at the end of the file.

Let me know if it worked, good luck!

本文标签: