Support

Account

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

Helping

Assigning category during block registration doesn't work

    • Nox

    • November 22, 2020 at 5:19 am

    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.

    • goldhat

    • November 26, 2020 at 5:00 am

    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.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.