close
Skip to content

[Template Activation] get_block_templates returns edited template as index #71770

@kmanijak

Description

@kmanijak

Description

Since template activation (#67125) the template slug for edited templates is always index. I'm using get_block_templates to retrieve a template.

For "default" template it's correct.

Step-by-step reproduction instructions

  1. Add this to your functions.php
add_filter(
	'get_block_templates',
	function ( $templates ) {
		array_map(
			function ( $template ) {
				do_action( 'qm/debug', $template->slug ); // use any method to log data
			},
			$templates
		);
		return $templates;
	},
	10,
	1
);
  1. Go to some page on the frontend that uses default template (e.g. 404)
  2. ->404 (or whatever you chosen)
  3. Go to Editor > Templates
  4. Duplicate some template and make it active
  5. Visit the page on the frontend
  6. -> index

The same goes for title, id, etc.

The issue has significant impact on WooCommerce templates logic causing among others this problem: woocommerce/woocommerce#61032

Screenshots, screen recording, code snippet

Logged:

  • slug
  • id
  • title
"Default" template "Edited" template
Image Image

Environment info

  • WordPress 6.8
  • Gutenberg 21.7RC
  • WooCommerce 10.3-dev

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

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

Labels

[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions