DEV Community

loading...
Cover image for How to Add a Link to Reusable Blocks in the Wordpress Admin Menu

How to Add a Link to Reusable Blocks in the Wordpress Admin Menu

sodevious profile image Nicole Dominguez ・1 min read

Sharing this little snippet because it took me way too much time to find this solution!

Wordpress offers the ability to save blocks as "reusable blocks" with Gutenberg. Often, users may want to manage or import these blocks. To access this page users have to open a post or page, click through to a block, open the options panel, click "Manage Reusable Blocks", etc. To make this easier, this function will add a Reusable Blocks submenu link in the Pages section of the Wordpress admin.

function add_reusable_blocks_link () {
  add_posts_page( 'Reusable Blocks', 'Blocks', 'edit_posts', 'edit.php?post_type=wp_block', '', 1);
}

add_action('admin_menu', 'add_reusable_blocks_link');
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

Forem Open with the Forem app