pre-populating new post (CPT) with pattern stopped working after updating to 16.6.0 #54619
noah-ri
started this conversation in
Developer Experience
Replies: 1 comment
-
Hi @noah-ri, Does this problem also occur with the latest Gutenberg? I tried testing using the code below, but could not reproduce it. function template_test() {
// Register custom post type
$args = array(
'public' => true,
'label' => 'Books',
'show_in_rest' => true,
);
register_post_type( 'book', $args );
// Define an initial pattern for the `book` post type
$post_type_object = get_post_type_object( 'book' );
$post_type_object->template = array(
array(
'core/pattern',
array(
'slug' => 'twentytwentyfour/banner-hero',
),
),
);
}
add_action( 'init', 'template_test' ); ab7d167cf575c7830d03cac09735ffb2.mp4 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I use a pattern (stored in the patterns-folder) to pre-populate the post whenever a new post of my custom post type is created. This worked fine until i updated Gutenberg to 16.6.0.
Now the pattern will not be displayed in the editor and not be editable (represented as only one block that says "This block has encountered an error and cannot be previewed."), will show in the frontend tho.
If i duplicate the block i get my pattern, it's editable and everything works fine, also if i insert my pattern with the inserter everything works fine.
Here's the code i'm using to load the pattern (in functions.php):
adding other blocks instead of the pattern works well, just not a pattern (regardless of it's content).
For now i fixed it by disabling the plugin but that's not a long term solution.
Any ideas what this could be caused by and/or how to fix it?
thank you!
Beta Was this translation helpful? Give feedback.
All reactions