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

FSE - Template meta information and post type support do not work #31704

Closed
rufus87 opened this issue May 11, 2021 · 3 comments · Fixed by #35802
Closed

FSE - Template meta information and post type support do not work #31704

rufus87 opened this issue May 11, 2021 · 3 comments · Fixed by #35802
Assignees
Labels
[Feature] Template Editing Mode Related to the template editor available in the Block Editor [Status] In Progress Tracking issues with work in progress

Comments

@rufus87
Copy link

rufus87 commented May 11, 2021

Description

Custom template configuration in experimental-theme.json file does not work neither in default themes nor in custom ones.

Step-by-step reproduction instructions

  1. Create my-custom-template.html file within current active theme's "block-templates" folder
  2. Add configuration from Code snippet part to active theme's experimental-theme.json file
  3. Go to admin panel and go to "Posts -> Add New"
  4. In the opened screen open "Template dropdown"

Expected behaviour

  1. Template dropdown should not contain above mentioned my-custom-template as an option because it should not be available for any post type but page.
  2. The template name must be read as The template title instead of my-custom-template based on experimental-theme.json file configuration

Actual behaviour

  1. Template is available in all post types: postTypes restriction does not work
  2. Template name is read as my-custom-template instead of The template title

Screenshots or screen recording (optional)

image
image
image

Code snippet (optional)

...
"customTemplates": [
    {
      "name": "my-custom-template",
      "title": "The template title",
      "postTypes": [
        "page"
      ]
    }
  ]
...

WordPress information

  • WordPress version: 5.7.1
  • Gutenberg version: 10.5.4
  • Are all plugins except Gutenberg deactivated? Yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? No

Device information

  • Device: Desktop
  • Operating system: Windows 10
  • Browser: Chrome 90.0.4430.93 (Official Build) (64-bit)
@rufus87 rufus87 changed the title Template meta information and post type support do not work FSE - Template meta information and post type support do not work May 11, 2021
@carolinan carolinan added the [Feature] Template Editing Mode Related to the template editor available in the Block Editor label May 11, 2021
@rufus87
Copy link
Author

rufus87 commented May 11, 2021

Hi there,

Many thanks for your feedback, however it is not visible here.

Seams like you did not understand the issue correctly. The template appears in "Templates" dropdown in any post type, ie: "postTypes" restriction in experimental-theme.json file does not work. Right now "postTypes" is set to ['page'], but template is available for selecting in Templates dropdown when I try to add post - not page, as well as the template filename appears in dropdown instead of the configured title. There is no difference how template file is named, does it have page- prefix or not.

Thanks

@Aljullu
Copy link
Contributor

Aljullu commented May 31, 2021

I can reproduce this as well. For example, if I create a single-product.html template and then I add:

"customTemplates": [
	{
		"name": "single-product",
		"title": "Product page",
		"postTypes": [
			"product"
		]
	}
]

to my theme.json, the single-product template is still available in pages and posts. Also, the title property is ignored and the template is listed as single-product instead of Product page.

It seems to be related to this TODO comment in the code:

// TODO: exclude templates that are not concerned by the current post type.

I think this was regressed in #30438, specifically in these changes: 7c134eb#diff-603069a6df3015f09478e5ed97c90a404f2e17fb29dc7af5467dac8131acc1c6. cc @youknowriad for awareness and in case you think this is something that needs to be prioritized.

@Mamaduka
Copy link
Member

Created PR that should fix the customTemplates title issue - #35592.

I'm working on excluding templates based on "postTypes" PR should be ready shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Template Editing Mode Related to the template editor available in the Block Editor [Status] In Progress Tracking issues with work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants