Skip to content

Templates added with 'theme_templates' filters can't be selected or swapped #64811

@dlh01

Description

@dlh01

Description

Custom page templates added with the theme_templates or theme_{$post_type}_templates filters can no longer be selected in the post editor. If a post is assigned a template that was previously made available through one of these filters, the template panel doesn't appear at all.

My guess is that this change occurred in #56817, but I didn't verify that.

Step-by-step reproduction instructions

  1. Add the demonstration filter below to a site running WordPress 6.4 or earlier.
  2. Edit a post, and assign it My Custom Template using the template panel.
  3. Update the site to WordPress 6.5 or later.
  4. Open the post in the post editor, and observe that the template panel doesn't appear.
  5. Create a new post in the post editor, and observe that My Custom Template can't be selected in the template panel.

Screenshots, screen recording, code snippet

add_filter(
	'theme_templates',
	function ( $post_templates ) {
		$post_templates['my-custom-template'] = 'My Custom Template';

		return $post_templates;
	},
);

Environment info

WordPress 6.4–6.6 with the default theme. Gutenberg isn't installed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Templates APIRelated to API powering block template functionality in the Site Editor[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    Status

    🦵 Punted to 7.0

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions