Created
January 16, 2019 11:11
-
-
Save nickcernis/f3e765a11cf3274a9aafd5150912ef84 to your computer and use it in GitHub Desktop.
Wrap Custom HTML WordPress blocks in a div wrapper
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 | |
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