Support

Account

Home Forums Gutenberg Assigning category during block registration doesn't work

Helping

Assigning category during block registration doesn't work

  • Hi,

    I wanted my block to be registered in the core “layout” category. According to the documentation, the function seem to wait for a parameter called “category” like in the wordpress register block function :

    add_action('acf/init', 'rt_block_section');
    function rt_block_section() {
    
    	if( function_exists('acf_register_block') ) {
    		acf_register_block(array(
                'title'			    => __( 'Section', 'rt' ),
                'name'			    => 'section',
                'category'          => 'layout',
                'keywords'			=> array( 'section' ),
    			'mode'				=> 'preview',
                'render_template'	=> 'template-parts/blocks/section.php',
                'supports'		    => [
                    'align'			    => false,
                    'anchor'		    => true,
                    'customClassName'	=> true,
                    'jsx' 			    => true,
                ],
    		));
    	}
    }

    However my block remains displayed in the “text” category, and not in the “layout” category.

    First I though it was a problem due to cache, so I cleared it manually, but it didn’t change anything. Any idea about how I can fix it ?

    Thank you in advance.

  • Maybe it needs an array instead of a single cat name such as ['layout'] because I think you can add multiple like ['layout', 'custom'].

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.