The standard Lorem Ipsum passage, used since the 1500s

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC

"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"

Add div+class around Shortcode block

The default WordPress Gutenberg Shortcode block has no setting at all. There is no option to make the block class alignwide or alignfull and there are no block settings to add a custom class..

I generally add the shortcode block to a Group block so I can use the options and settings of the Group block and use alignwide or alignfull.

You can also add a div around a shortcode by adding it around the shortcode manually

And you can even add this code snippet to your functions.php to add this class to all shortcode-blocks.

// Add div with class alignfull around shortcode block
add_filter( 'render_block', function( $block_content, $block ) {
    // Target shortcode blocks
    if ( preg_match( '~^core/shortcode|core-embed/shortcode~', $block['blockName'] ) ) {
       $block_content = sprintf( '<div class="alignfull">%s</div>', $block_content );
    }
    return $block_content;
}, PHP_INT_MAX - 1, 2 );

PS: In the TwentyTwenty theme the alignwide and alignfull class on the Group block don’t make the Shortcode block show the correct way due to the following css on line 3556 of the style.css

[class*="__inner-container"] > *:not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright):not(.is-style-wide) {
    max-width: 58rem;
    width: 100%;
}

So if the block inside the inner-container of the Group block has NO align*** class the max-width is 58rem.

I couldn’t find a feature request on the WordPress support forums so I added one: https://github.com/WordPress/gutenberg/issues/21315

Related post

Leave a Reply