Make WordPress Core

Opened 15 months ago

Last modified 11 days ago

#58236 new defect (bug)

theme.json customTemplates with child themes work wrong

Reported by: thomask's profile thomask Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.3
Component: Editor Keywords: needs-testing
Focuses: template Cc:

Description

If you use child themes, then customTemplates in theme.json does not work and behaves badly

  1. It is not possible to delete or overwrite parent custom template - neither false nor empty array helps
  2. It is not possible to create a new custom template - it simply does not appear
  3. and what is strange - if you try to create your own custom template, it will throw away the naming and parent template at that position, so then when you select the template for the page, it doesn't show the title but the name. Example - if you make a child theme from twenty-three, and you type
	"customTemplates": [
		{
			"name": "no-title",
			"postTypes": [
				"page"
			],
			"title": "No title"
		}],

so when the page is selected, it will display 'blank' instead of 'Blank' (blank is the name of the first template in the parent twenty-three theme). If you try

	"customTemplates": [{},
		{
			"name": "no-title",
			"postTypes": [
				"page"
			],
			"title": "No title"
		}],

so when you select a page, it will display "blog-alternative" instead of Blog (Alternative) (blog-alternative is the second template in the parent theme).
Child template can't be added like this even in the fourth position

Unfortunately, this makes the whole thing completely unusable.

Attachments (2)

Snímek obrazovky 2023-05-02 210412.png (75.4 KB) - added by thomask 15 months ago.
This is an example of that mentioned third problem
Snímek obrazovky 2023-05-02 211740.png (30.5 KB) - added by thomask 15 months ago.
that wrong named parent template is shown also in the left list of templates on site-editor.php

Download all attachments as: .zip

Change History (3)

@thomask
15 months ago

This is an example of that mentioned third problem

@thomask
15 months ago

that wrong named parent template is shown also in the left list of templates on site-editor.php

#1 @poena
11 days ago

  • Keywords needs-testing added

Hi @thomask

I am not sure that all of the issues are existing bugs. They may have been solved since WordPress 6.3, are you available to test them again?

1) To delete a parent theme template with a child theme, add an empty file with the same file name. The parent template will no longer be selectable.

2) To replace an existing parent theme template with a template in a child theme, you also add a file with the same name.

  • If I use a HTML template, I am not able to reproduce the part where you are saying that the child theme template is not showing. In my test I am able to use the child theme template.
  • If I try to replace it with a PHP template, it is not showing as an option in the block editor, it can't be selected. See https://core.trac.wordpress.org/ticket/61210

3) I am not able to reproduce this using 6.6 RC2.

Note: See TracTickets for help on using tickets.