• Hello,

    I did override the core block for the gallery using in my functions.php file :

    <?php
    function my_register_gallery() {
            unregister_block_type('core/gallery');
            register_block_type( 'core/gallery', array(
                    'render_callback' => 'my_gallery_render',
            ) );
    }
    add_action( 'init', 'my_register_gallery', 10 , 1  );

    It was perfectly working, but since a few days (I did the last update of wordpress 5.8.1), and maybe a little bit before, but I am not totally sure, I have an issue:

    If I use the unregister_block_type function I cannot override it with register_block_type and the block disappear in the editor. And a strange thing occurs, I have this message on the former existing gallery blocks :

    Your site doesn’t include support for the THRON block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.

    If I don’t use unregister_block_type('core/gallery'); before, I have this message :

    Notice: WP_Block_Type_Registry::register was called incorrectly. Block type "core/gallery" is already registered. Please see Debugging in WordPress for more information. (This message was added in version 5.0.0.) in /Users/the_user/wordpress_folder/wp-includes/functions.php on line 5663

    All of that was working before with no alert.
    I tried with all my plugins deactivated, and with removing all my function.php files actions.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Override core/gallery block’ is closed to new replies.