Block pattern do not show in the inserter
Is there an existing issue for this?
- [X] I have searched the existing issues
Have you tried deactivating all plugins except Gutenberg?
- [X] I have tested with all plugins deactivated.
Have you tried replicating the bug using a default theme e.g. Twenty Twenty?
- [X] I have tested with a default theme.
Description
Hello, since the update to version 5.8, this simple pattern is no longer displayed in the inserter.
register_block_pattern(
"mywpsite/test",
[
"title" => esc_html__("Test"),
"categories" => ["mywpsite-default"],
"content" => trim(str_replace(["\n", "\r", "\t"], "", '
<!-- wp:columns --><div class="wp-block-columns">
<!-- wp:column --><div class="wp-block-column">
<!-- wp:heading -->
<h2>Hello world</h2>
<!-- /wp:heading -->
</div><!-- /wp:column -->
</div><!-- /wp:columns -->
')),
]
);
Whenever I remove the column, the pattern is shown up.
Step-by-step reproduction instructions
- Add the code above to functions.php
- Open WordPress and edit a post
- The pattern is not displayed in the inserter on the left side
Expected Behavior
Show up in the inserter
Current Behavior
Will not be shown
Screenshots or screen recording (optional)
No response
Code snippet (optional)
No response
WordPress Information
No response
Gutenberg Information
No response
What browsers are you seeing the problem on?
No response
Device Information
No response
Operating System Information
No response
Hey 👋 - thanks for reporting this! I couldn't reproduce this though... Have you registered your category with register_block_pattern_category? If not, the pattern is shown under Uncategorized in the inserter.
Yes. Sorry, here's the complete code:
<?php
remove_theme_support("core-block-patterns");
add_action("init", function () {
if (function_exists("register_block_pattern_category")) {
register_block_pattern_category(
"mywpsite-default",
["label" => esc_html__("Presets")]
);
}
if (function_exists("register_block_pattern")) {
register_block_pattern(
"mywpsite/test",
[
"title" => esc_html__("Test"),
"description" => "",
"keywords" => [],
"categories" => ["mywpsite-default"],
"content" => trim(str_replace(["\n", "\r", "\t"], "", '
<!-- wp:columns --><div class="wp-block-columns">
<!-- wp:column --><div class="wp-block-column">
<!-- wp:heading -->
<h2>Lorem ipsum dolor sit amet vis</h2>
<!-- /wp:heading -->
<!-- wp:paragraph -->
<p>Lorem ipsum dolor sit amet, nam nonumy dicunt voluptua ne. Idque nullam expetenda ex pro. Mandamus deseruisse reformidans mei ei. Saepe mucius admodum mel in, cu mei qualisque neglegentur. In tantas forensibus his, ullum atomorum te est, ad quod ponderum est. Te ius offendit comprehensam, at usu sumo reque nusquam.</p>
<!-- /wp:paragraph -->
</div><!-- /wp:column -->
</div><!-- /wp:columns -->
')),
]
);
}
});
If I replace the content with this, it is shown:
…
"content" => trim(str_replace(["\n", "\r", "\t"], "", '
<!-- wp:heading -->
<h2>Lorem ipsum dolor sit amet vis</h2>
<!-- /wp:heading -->
<!-- wp:paragraph -->
<p>Lorem ipsum dolor sit amet, nam nonumy dicunt voluptua ne. Idque nullam expetenda ex pro. Mandamus deseruisse reformidans mei ei. Saepe mucius admodum mel in, cu mei qualisque neglegentur. In tantas forensibus his, ullum atomorum te est, ad quod ponderum est. Te ius offendit comprehensam, at usu sumo reque nusquam.</p>
<!-- /wp:paragraph -->
')),
…
So, it seems to be an issue with the column-block.
Your full code doesn't change much to the previous snippet, and for me it still works... 🤔 I guess other folks could test this as well..
I tested it with the full code @moerphie posted above, and yes it works okay for me too.



Sorry I can't see any issues with the code that would stop it from displaying!
Another potential issue for your case @moerphie would be that in your Preferences you have Columns block disabled, or in general this block unregistered/disabled. Patterns are filtered for containing allowedBlocks, so if you have Columns disabled, it would not be shown.
Would that be the case for you?
Another potential issue for your case @moerphie would be that in your
Preferencesyou haveColumnsblock disabled, or in general this block unregistered/disabled. Patterns are filtered for containingallowedBlocks, so if you haveColumnsdisabled, it would not be shown.Would that be the case for you?
Good advice! In fact, this was the issue.
core/columns was an allowed block type, but core/column was not included.
In version 5.7 this was not a problem, but with 5.8 it now triggered the error.
Thank you!