on-internet
← Community

How to create a custom Gutenberg block with a dynamic render callback in WordPress?

Stack Overflow ·

I'm trying to create a custom Gutenberg block in WordPress that renders its content dynamically on the server side using PHP. I've registered the block using register_block_type, and added a render_callback function, but nothing appears in the editor or frontend. function myplugin_register_block() { register_block_type( __DIR__ . '/my-block', array( 'render_callback' => 'myplugin_render_my_block', )); } add_action( 'init', 'myplugin_register_block' ); function myplugin_render_my_block( $attributes ) { return '<div class="dynamic-block">Hello, this is dynamic content!</div>'; } import { registe

Comments

Sign in or sign up to comment and upvote.

No comments yet.