Add or Remove Buttons to WordPress Editor: The WordPress editor has buttons that allow you to insert popular HTML tags. I do not use all the buttons that are in the default WordPress editor.
But at the same time, I really miss the buttons to insert the H2 and H3 tags. Therefore, in this article I will show you how to add buttons you need and remove unused ones.
How to add buttons to HTML editor WordPress
For new buttons to appear on the WordPress editor panel, you need to add the functions.php
following code to your theme file :
<? php
add_action ('admin_print_footer_scripts', 'appthemes_add_quicktags');
function appthemes_add_quicktags () {
if (! wp_script_is ('quicktags'))
return;
?>
<script type = "text / javascript">
QTags.addButton ('eg_h2', 'h2', '<h2>', '</h3>', '', 'Heading h2', 51);
QTags.addButton ('eg_h3', 'h3', '<h3>', '</h3>', '', 'Heading h3', 61);
QTags.addButton ('eg_pre', 'pre', <pre> ',' </pre> ',' ',' Preformatted text ', 101);
QTags.addButton ('eg_accent', 'Accent Mark', '& # x301;', '', '', 'Put Accent Mark');
</script>
<? php
}
?>
In my example, I will add buttons for the heading H2, H3 and the PRE preformatted text tag. You can add your own buttons by changing the given code to your liking.
How to remove default buttons in WordPress
To remove buttons, you need to add the following code to functions.php
your WordPress theme file :
// Remove unnecessary buttons from the rectator
add_filter ('quicktags_settings', 'set_buttons_for_html_editor');
function set_buttons_for_html_editor ($ buttons) {
$ buttons ['buttons'] = 'strong, em, link, block, ul, ol, li, code, more, close, fullscreen';
return $ buttons;
// default: $ buttons ['buttons'] = 'strong, em, link, block, del, ins, img, ul, ol, li, code, more, close, fullscreen';
}
In this example, I will remove the extra buttons for the del, ins and img HTML tags, since I am not using them. The variable $buttons['buttons']
should contain the buttons you want to keep.
Be the first to post a comment.