-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
Description
This PR merged last week introduced the ability to "swap templates" for pages. However, something in this PR has broken the page template hierarchy, meaning in the site editor only, it claims the "Pages" template is in use, when in fact a custom template exists.
As an example, in this case there is a template called page-cart. This is also registered via the page_template_hierarchy filter to ensure it has priority over all other templates. Before #51477 this is what you would see in the page editor:
After #51477 you can see it now uses the generic "pages" template instead:
Whats more, the preview in the site editor also uses the "pages" template. The frontend views still use page-cart as before.
It seems as though the issues are:
- Hierarchy is no longer respected in the site editor
- Swap template functionality should not be available if a custom template is in place
Step-by-step reproduction instructions
We're running into this issue with WooCommerce Blocks which includes a cart template which should be the default.
- Install latest WooCommerce
- Checkout and build blocks from trunk https://github.com/woocommerce/woocommerce-blocks.
nvm use && npm install && npm run build - Activate both and setup as normal. After setup you should have both a "cart" and "checkout" page under pages.
- Go to Appearance > Editor > Pages > Cart. See in the inspector it says the template being used is "Pages". Notice the preview uses the "pages" template
- Checkout gutenberg with SHA 7d054a2. This is before [Site Editor - Page Inspector]: Add ability to switch templates #51477
- Go to Appearance > Editor > Pages > Cart. See in the inspector it says the template being used is "Page: Cart". Notice the preview uses the "Page: Cart" template (no comments or featured image is visible).
Screenshots, screen recording, code snippet
No response
Environment info
- Latest Gutenberg from trunk
- Twenty Twenty Three
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
No

