Created
April 28, 2022 14:44
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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