Creating Pattersn
-
Hi Everyone, I’m not really sure if I’m asking in the right place. I’m working on creating some patterns for a site a run to make it easier for the user to create pages and posts. I’ve managed to get the basics of a plugin working with one pattern. However, when I added a second one to the same patterns file it only seems to display one. I’m not sure if its something to do with the category I created or not. Here is my code some help would be great. Thanks.
<?php function southern_europe_block_patterns() { register_block_pattern_category( 'Scouts', array( 'label' => __( 'Scouts', 'southern-europe-block-patterns' ) ) ); register_block_pattern( 'southern-europe-block-patterns/southern-europe-content-upgrade', array( 'title' => __( '70/30 Sidebar Layout', 'southern-europe-block-patterns' ), 'description' => _x( 'This is a 70/30 sidebar layout.', 'southern-europe-block-patterns' ), 'content' => "<!-- wp:columns -->\r\n<div class=\"wp-block-columns\"><!-- wp:column {\"width\":\"66.66%\"} -->\r\n<div class=\"wp-block-column\" style=\"flex-basis:66.66%\"><!-- wp:heading -->\r\n<h2 id=\"temp-heading-1\">Temp Heading</h2>\r\n<!-- /wp:heading -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>There are many more blocks that will help with the quicker building of a page or post, all of these can be found under the pattern tab of the blue/black plus button.</p>\r\n<!-- /wp:paragraph --></div>\r\n<!-- /wp:column -->\r\n\r\n<!-- wp:column {\"width\":\"33.33%\"} -->\r\n<div class=\"wp-block-column\" style=\"flex-basis:33.33%\"><!-- wp:spacer {\"height\":20} -->\r\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"></div>\r\n<!-- /wp:spacer -->\r\n\r\n<!-- wp:group {\"backgroundColor\":\"scout-blue\",\"textColor\":\"white\"} -->\r\n<div class=\"wp-block-group has-white-color has-scout-blue-background-color has-text-color has-background\"><!-- wp:spacer {\"height\":15} -->\r\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"></div>\r\n<!-- /wp:spacer -->\r\n\r\n<!-- wp:heading {\"level\":4} -->\r\n<h4 id=\"temp-heading\">Temp Heading</h4>\r\n<!-- /wp:heading -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>This is a basic block for the side bar, to insert one just like this go to '+' button, patterns and select 'Sidebar Block'</p>\r\n<!-- /wp:paragraph -->\r\n\r\n<!-- wp:spacer {\"height\":10} -->\r\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"></div>\r\n<!-- /wp:spacer --></div>\r\n<!-- /wp:group --></div>\r\n<!-- /wp:column --></div>\r\n<!-- /wp:columns -->\r\n\r\n<!-- wp:paragraph -->\r\n<p></p>\r\n<!-- /wp:paragraph -->", 'categories' => array( 'Scouts' ), ) ); register_block_pattern( 'southern-europe-block-patterns/southern-europe-content-upgrade', array( 'title' => __( 'Sidebar Block', 'southern-europe-block-patterns' ), 'description' => _x( 'This is a block for the side bar, of the 70/30 layout.', 'southern-europe-block-patterns' ), 'content' => "<!-- wp:paragraph -->\r\n<p></p>\r\n<!-- /wp:paragraph -->\r\n\r\n<!-- wp:group {\"backgroundColor\":\"scout-blue\",\"textColor\":\"white\"} -->\r\n<div class=\"wp-block-group has-white-color has-scout-blue-background-color has-text-color has-background\"><!-- wp:spacer {\"height\":15} -->\r\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"></div>\r\n<!-- /wp:spacer -->\r\n\r\n<!-- wp:heading {\"level\":4} -->\r\n<h4 id=\"temp-heading\">Temp Heading</h4>\r\n<!-- /wp:heading -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>This is a basic block for the side bar, to insert one just like this go to '+' button, patterns and select 'Sidebar Block'. You Can change the colours for text and background under the 'block' option on the left.</p>\r\n<!-- /wp:paragraph -->\r\n\r\n<!-- wp:spacer {\"height\":10} -->\r\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"></div>\r\n<!-- /wp:spacer --></div>\r\n<!-- /wp:group -->\r\n\r\n<!-- wp:spacer {\"height\":30} -->\r\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"></div>\r\n<!-- /wp:spacer -->", 'categories' => array( 'Scouts' ), ) ); } add_action( 'init', 'southern_europe_block_patterns' );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Creating Pattersn’ is closed to new replies.