Wordpress Custom Gutenberg Block render_callback doesnt render

admin

Administrator
Staff member
I'm trying to build a custom Gutenberg Block, which will be rendered dynamically (from PHP).
I've spent a significant amount of time searching for different solutions, minimized my code to the absolutely necessary, and still it doesnt work.
My main reference is this page: <a href="https://developer.wordpress.org/block-editor/tutorials/block-tutorial/creating-dynamic-blocks/" rel="nofollow noreferrer">https://developer.wordpress.org/block-editor/tutorials/block-tutorial/creating-dynamic-blocks/</a>
And here's my code:
PHP (functions.php):
Code:
function register_test_block(){

    wp_register_script('test-block',
        get_template_directory_uri().'/js/test-block.js',
        array('wp-blocks') );

    register_block_type('test/testblock', array(
            'render_callback' =&gt; function( $block_attributes, $content ) {
                return '&lt;p&gt;OMG SUCCESS!&lt;/p&gt;';
            },
            'editor_script' =&gt; 'test-block' )
    );
}

add_action('init', 'register_test_block');
test-block.js:
Code:
const { registerBlockType } = wp.blocks;


registerBlockType('test/testblock', {
    title: 'test block',
    edit: props =&gt; {
        return (&lt;p&gt;test&lt;/p&gt;);
    },
    save: props =&gt; {
        return null;
    }
});
i really have no idea why this isn't working as its supposed to, on the frontend the block is just not rendered at all, not even a comment or anything. Oh and my current WP Version is 5.5.3 with PHP 7.3 if this helps..
Does anyone know why my block isn't rendering? Thanks!