-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FSE: Fix template loading order for child themes when no explicit template exists #31336
Conversation
I'm not sure if I might be missing other important cases that I've not considered to test. |
Size Change: 0 B Total Size: 1.31 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works as described. The use case I verified:
- Child theme has an index.php
- Parent theme has an index.html
- Visited
/category/some-tag
and verified the child theme's index.php was loaded
Without this PR, the parent theme's index.html is loaded.
For sanity, I also checked if the parent theme has a higher matching template (e.g. archive.html / archive.php in my example), it loads this template correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This solves the issue, and the code looks good. I tested all the scenarios I could think of...
…plate exists (#31336) * formatting and comments * fix how we control the block template file
The block template resolution algorithm is quite complex, as it has to cover quite a lot of different possible cases resulting from various combinations of - WP's "old" template hierarchy (including custom page templates, and child themes) - block templates. Things become especially complex when there are e.g. "oldschool" PHP templates with higher specificity than the available block templates; or when a child theme has a PHP template with equal specificity as the parent theme's corresponding block template. For more discussion on this, see #31399. Examples of previous iterations that sought to refine the algorithms' behavior include #29026, #30599, #31123, and #31336. This PR's goal is to eventually cover all of those cases.
Description
This PR covers a condition that was not being considered by #31123: When a child theme has no explicit template for a certain page (such as the home.php) but it does have a fallback template available (such as index.php), the template that was being loaded was the one from the parent if it was using a block based template (in this example: index.html). This change encapsulates the previous PR to only consider child themes and covers this specific case that was not being considered.
How has this been tested?
Using a child of BCB I tested the following cases:
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist:
*.native.js
files for terms that need renaming or removal).