Edit location and color of custom blocks in Admin

Support MB Blocks Edit location and color of custom blocks in AdminResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #31503
    SHANDASHANDA
    Participant

    Hello,
    I am using Metabox to build custom blocks. I was able to give my blocks a custom title but would like to change where they are displayed in the Admin. Currently my blocks are after the Text, Media, Design, Theme, and Widgets blocks but I would like my blocks to display before the Text block at the top. Are you able to help me do this or direct me to some documentation for this issue?

    #31512
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You can create a custom block category, move it to the top and assign the block to that category. Refer to this documentation https://developer.wordpress.org/reference/hooks/block_categories_all/
    https://stackoverflow.com/questions/54185278/how-to-list-and-re-arrange-or-manipulate-gutenberg-block-categories-in-wordpress

    function wpdocs_add_new_block_category( $block_categories, $block_editor_context ) {
        $custom_category = [
            'slug'  => 'my-block-category',
            'title' => esc_html__( 'My Block Category', 'text-domain' ),
            'icon'  => 'wordpress', // Slug of a WordPress Dashicon or custom SVG
        ];
        $block_categories[0] = $custom_category;
        return $block_categories;
    }
    add_filter( 'block_categories_all', 'wpdocs_add_new_block_category', 10, 2 );
    #31563
    SHANDASHANDA
    Participant

    Oh, you are so awesome! Thank you

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.