• previous versions of wordpress had a pattern that was two images with two columns. This pattern no longer appears in the block builder. I know i can copy and paste it from wordpress.org, but i want to add it back into the block builder. Is there an easy way to do this. Any help greatly appreciated. Thanks

    • This topic was modified 4 years, 8 months ago by Jan Dembowski.
Viewing 1 replies (of 1 total)
  • One option would be to add the following to the likes of your themes functions.php file:

    register_block_pattern(
        'my-plugin/my-images-in-columns-pattern',
        array(
    		'categories'       => ['columns' ],
            'title'       => __( 'Two images', 'my-plugin' ),
            'description' => _x( 'Two images in a column block.', 'Block pattern description', 'my-plugin' ),
            'content'     => "<!-- wp:columns -->\n<div class=\"wp-block-columns\"><!-- wp:column -->\n<div class=\"wp-block-column\"><!-- wp:image {\"id\":27,\"sizeSlug\":\"full\",\"linkDestination\":\"none\"} -->\n<figure class=\"wp-block-image size-full\"><img src=\"https://s.w.org/images/core/5.8/nature-above-01.jpg\" alt=\"\" class=\"wp-image-27\"/></figure>\n<!-- /wp:image --></div>\n<!-- /wp:column -->\n<!-- wp:column -->\n<div class=\"wp-block-column\"><!-- wp:image {\"id\":26,\"sizeSlug\":\"full\",\"linkDestination\":\"none\"} -->\n<figure class=\"wp-block-image size-full\"><img src=\"https://s.w.org/images/core/5.8/nature-above-02.jpg\" alt=\"\" class=\"wp-image-26\"/></figure>\n<!-- /wp:image --></div>\n<!-- /wp:column --></div>\n<!-- /wp:columns -->",
        )
    );
    

    This would add a two image pattern to the Columns category. More details about adding patterns this way can be found at https://developer.wordpress.org/block-editor/reference-guides/block-api/block-patterns/

    There are also a number of plugins that allow you to easily add your own patterns to your site, eg. https://wordpress.org/plugins/search/block+patterns/

Viewing 1 replies (of 1 total)

The topic ‘Patterns’ is closed to new replies.