gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Site Editor: use of 'default_template_types' filter removes 404 title & description

Open Sandstromer opened this issue 5 years ago • 2 comments

Description

When making use of the default_template_types filter - e.g. to rename template or give a custom template a pretty name/description - the title and description of the 404 template is removed.

Step-by-step reproduction instructions

In a theme's functions.php file, add a filter to give the 'page-home' (a custom TT1-Blocks page template) a nice title and description:

add_filter( 'default_template_types', 'tt1_blocks_additional_template_types' );

function tt1_blocks_additional_template_types( $default_template_types ) {
	
	$add_template_types = array(
		'page-home' => array(
			'title'       => _x( 'Page without title', 'Template name', 'tt1-blocks' ),
			'description' => __( 'Template used to display the homepage without a title.', 'tt1-blocks' ),
		)
	);
	
	$default_template_types = array_merge( $add_template_types, $default_template_types );
	
	return $default_template_types;

}

Go into Site Editor and select a template to edit.

In the left sidebar - Theme > Templates - notice the title and description of the default 404 template are now missing.

Note: the slug and title of the 404 template are identical, but if one changes the title of the 404 template in /lib/full-site-editing/default-template-types.php to test, then we can see the title is replaced with the slug.

Expected behaviour

Actual behaviour

Screenshots or screen recording (optional)

Before and after adding filter

Before After
image image

(Note that the new template type added by the filter appears under "General templates")

Code snippet (optional)

WordPress information

  • WordPress version: 5.7
  • Gutenberg version: 10.3.2
  • Are all plugins except Gutenberg deactivated? Yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? TT1-Blocks

Device information

  • Device:
  • Operating system:
  • Browser:

Sandstromer avatar Apr 12 '21 15:04 Sandstromer

Note that I added some screenshots to the issue description to illustrate the issue:

Before After
image image

creativecoder avatar Oct 21 '21 22:10 creativecoder

The navigation changed a bit and I can't seem to reproduce this anymore.

youknowriad avatar Feb 24 '23 12:02 youknowriad