Skip to content

Snippet: Add Custom Block to Post Content Builder Element

Important: Your custom callback function must be whitelisted or it will not work. This is for security reasons. Learn more →
/**
 * Register new block for the Post Content element.
 *
 * @link https://totalwptheme.com/docs/snippets/custom-block-post-content-module/
 */
add_filter( 'vcex_post_content_blocks', function( $blocks ) {
	$blocks['my_custom_block_callback'] = 'My Custom Block Name';
	return $blocks;
} );

/**
 * Callback function for the "my_custom_block_callback" Post Content element block.
 */
function my_custom_block_callback() {
	echo 'custom block output';
}
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top