Skip to content

Instantly share code, notes, and snippets.

@deckerweb
Forked from nickcernis/functions.php
Created April 8, 2019 20:03
Show Gist options
  • Save deckerweb/d564e13eb4706a369e007604f8e5a058 to your computer and use it in GitHub Desktop.
Save deckerweb/d564e13eb4706a369e007604f8e5a058 to your computer and use it in GitHub Desktop.
Wrap Custom HTML WordPress blocks in a div wrapper
<?php
add_filter( 'render_block', 'custom_wrap_html_block_output', 10, 2 );
/**
* Wrap output of HTML blocks.
*
* @param string $block_content Original block content.
* @param array $block Block info.
* @return string The block content with a wrapper.
*/
function custom_wrap_html_block_output( $block_content, $block ) {
if ( 'core/html' === $block['blockName'] ) {
$block_content = '<div class="test">' . $block_content . '</div>';
}
return $block_content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment