Skip to content
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

Bug: Gutenberg Plugin v13.9+ - Template Attribute for PHP template & theme.json conflict #45216

Closed
sethwhitaker opened this issue Oct 21, 2022 · 5 comments
Labels
[Package] Edit Post /packages/edit-post [Type] Bug An existing feature does not function as intended

Comments

@sethwhitaker
Copy link

Description

Ever since Gutenberg Plugin v13.9+ the simple existence of the theme.json file in the theme causes the template label to always say Default Template if its been set to a custom PHP template. Clicking on the Label to open the popup still correctly shows which template is actually set for the page.

I came across this PR #42091 when looking to see if anyone has had similar experiences. The comment by noisysocks in that conversation is the exact issue im having but based on the remainder of the conversation, i assume it was fixed before merge. There is some discussion at the bottom about settings.availableTemplates[] but I cant find any documentation on that anywhere. Is this something I need in my theme.json to define my PHP templates? Do i have to disable block templates? Id like to have the ability to have both block and classic as im primarily developing in a hybrid approach.

At this point im not 100% sure if this is still a bug or if Im just missing something somewhere.
Ive created a simple theme with just a basic index.php, style.css, theme.json and custom-template.php so there are no conflicts anywhere.

bug-template-attribute

If I remove the theme.json file from the theme, then it shows up correctly.

correct-template-attribute

This only appears to affect classic PHP templates. As below I created an FSE Template and it works as expected even with the theme.json in the theme.

FES-template-attribute

Step-by-step reproduction instructions

  1. Go to page
  2. Click on template title
  3. Cange to custom PHP template
  4. Template title does not change to reflect chosen template

Screenshots, screen recording, code snippet

FES-template-attribute
bug-template-attribute
correct-template-attribute

Environment info

  • Wordpress - v6.0.3
  • Gutenberg - v13.9+

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@sethwhitaker
Copy link
Author

If I add remove_theme_support( 'block-templates' ); to functions.php then the template title works as expected. But I do not wish to need to add this to the theme if I do not need too.

Is it not possible to use block templates and classic templates together?

@skorasaurus skorasaurus added [Type] Bug An existing feature does not function as intended [Package] Edit Post /packages/edit-post labels Oct 22, 2022
@skorasaurus
Copy link
Member

Thanks for the thorough, detailed report.

I have the same experience as well; using Gutenberg 14.0.3 (haven't tested other versions at the time) on a custom theme that uses theme.json and no block-based templates.

From reading over the discussion at #42091 ; that behavior (the name of the template type should be loaded) should be fixed but it is not.

@noisysocks or @Mamaduka could you clarify if this has not been fixed?

@sethwhitaker
Copy link
Author

Good to know that this should be working but maybe isn't. Thought I was going crazy.

@noisysocks
Copy link
Member

Can confirm this also by activating Twenty Twenty and creating an empty wp-content/themes/twentytwenty/theme.json file.

@Mamaduka: Looking at https://github.com/WordPress/gutenberg/pull/42091/files. The presence of theme.json causes supportsTemplateMode to be true. I'm not really sure how to fix this while also making it so that Default template isn't shown in block themes.

@Mamaduka
Copy link
Member

Mamaduka commented Dec 5, 2022

This should be resolved after #46304.

@Mamaduka Mamaduka closed this as completed Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Edit Post /packages/edit-post [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants