How to add custom button to gutenberg Wordpress Editor

Using JS is one way we can achieve that,

Firstly add below code into your theme function.php

function add_scripts_editor(){
    wp_enqueue_script('mytheme', get_stylesheet_directory_uri() . '/js/mytheme.js', array('jquery'), '', true );
}
add_action('admin_enqueue_scripts', 'add_scripts_editor');

Then create mytheme.js into your js folder and add the below code into it. Now open any POST/PAGE type and your Back Button is added, you can add any link to it to navigation to your user he want to go back.

Tags
Subscribe to word