Support » Plugin: Gutenberg » Category and Blocks are registered but not listed in insert button

  • Greetings,

    I have registered my category and blocks as I did in other themes but it is not listed in the plus/insert button.

    — Here is the testing code (registering code below)

    wp.blocks.getCategories() >> shows my category

    wp.blocks.getBlockType(‘melange/container’); >> gets an object

    — And here is the registering code

    registerBlockType( ‘melange/contactform’, {
    category: ‘melange’,
    icon: ‘universal-access-alt’,
    title: ‘Contact’,
    description: ‘Contact form’,

    });

    function melange_editor_assets() {
    if(is_admin()) {
    wp_register_script( ‘melange’, plugins_url(‘melange/blocks.js’), array(‘wp-blocks’, ‘wp-element’, ‘wp-editor’) );
    wp_register_style ( ‘melange’, plugins_url(‘melange/blocks.css’), array(‘wp-edit-blocks’) );
    wp_enqueue_script ( ‘melange’ );
    wp_enqueue_style ( ‘melange’ );
    }
    }

    add_action( ‘enqueue_block_editor_assets’, ‘melange_editor_assets’ );

    function melange_categories($categories, $post) {
    $categories = array_merge(
    $categories,
    array(
    array(
    ‘slug’ => ‘melange’,
    ‘title’ => ‘Melange ·[add-on]·’,
    ‘icon’ => ‘dashicons-align-left’,
    ),
    )
    );
    return $categories;
    }

    add_filter( ‘block_categories’, ‘melange_categories’, 10, 2 );

    — It works when I do:

    function melange_allowed_block_types( $allowed_blocks ) {
    $allowed_blocks = array(
    ‘melange/contactform’,
    );
    return $allowed;
    }

    add_filter( ‘allowed_block_types’, ‘melange_allowed_block_types’ );

    But then I lost the blocks from other plugins

    Many thanks in advance for your help,
    – Albin

    • This topic was modified 4 years, 5 months ago by Albin.
  • The topic ‘Category and Blocks are registered but not listed in insert button’ is closed to new replies.