This is very useful if you need to add a button that adds some HTML in your page/post.

To add such a button, paste the following code in your theme’s functions.php:

// add more buttons to the html editor
function appthemes_add_quicktags() {
    if (wp_script_is('quicktags')){
?>
    <script type="text/javascript">
    QTags.addButton( 'eg_paragraph', 'BUTTON TITLE', 'CODE OR TEXT TO BE ADDED', '', '', 'BUTTON ALT', 9 ); // 9 refers to the position of the button in the editor.
    </script>
<?php
    }
}
add_action( 'admin_print_footer_scripts', 'appthemes_add_quicktags' );

 

Source: https://codex.wordpress.org/Quicktags_API