Skip to content

Patterns not working anymore as a post template #55846

@renatho

Description

@renatho

Description

Pattern block as a post template is not working anymore on the latest versions of Gutenberg. If fires an error on the block editor load, and breaks the block.

We realized that while testing Sensei LMS plugin on WP 6.4 because some custom post types are now broken there. It's also reported in Automattic/sensei#7262 as part of one of the Sensei post types.

Step-by-step reproduction instructions

  1. Create a new post type with a template by using the following snippet:
    add_action( 'init', function() {
        register_post_type(
    	    'my-test',
    	    [
    		    'public'       => true,
    		    'show_in_rest' => true,
    		    'template'     => [
    			    [
    				    'core/pattern',
    				    [ 'slug' => 'core/simple-header-with-dark-background' ],
    			    ],
    		    ]
    	    ]
        );
    } );
  2. Create a new post of this new post type.
  3. See the error in the editor.
  4. Open the browser console and see the JS error.

Screenshots, screen recording, code snippet

Screenshot 2023-11-01 at 11 48 33

Environment info

  • Tested on WP 6.4 RC2 or with Gutenberg plugin activated version 17.0.0-rc.1.
  • Reproduced on Chrome and Firefox.

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

Labels

[Status] In ProgressTracking issues with work in progress[Type] RegressionRelated to a regression in the latest release

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions