Skip to content

Instantly share code, notes, and snippets.

@ryanwelcher
Created April 28, 2022 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanwelcher/b0efd0316c04a295a31389059af424a5 to your computer and use it in GitHub Desktop.
Save ryanwelcher/b0efd0316c04a295a31389059af424a5 to your computer and use it in GitHub Desktop.
WordPress 6.0 Example: Allowing a block patter to be show as a suggestion on new Pages.
<?php
/**
* Example showing how to allow a block pattern to be shown as a suggested pattern for new Pages.
*/
add_action(
'init',
function() {
register_block_pattern(
'block-pattern-suggestion-example',
array(
'title' => __( 'Example Block Pattern to be shown on new Pages', 'pattern-suggestion-example' ),
'categories' => array( 'pages' ),
'blockTypes' => array('core/post-content'), // Add this line to allow this pattern to be shown as a pattern suggestion.
'content' => '
<!-- wp:paragraph {"fontSize":"small"} -->
<p class="has-small-font-size">Example Content</p>
<!-- /wp:paragraph -->',
)
);
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment