
In this WordPress tutorial I will explain how to add a new custom quick tag button in WordPress editor.
You can use this method in your theme or plugin to add a new quick tag button in WordPress editor.
Now we are going to a new quick tag button
Add following codes at the bottom of functions.php of your theme or plugin's main php file.
<?php
// Add New Custom Quicktag button
function gelcode_add_quicktags() {
if (wp_script_is('quicktags')){
?>
<script type="text/javascript">
QTags.addButton( 'eg_gelcode', 'GelCode', '', ' ', 'GelCode', 'My New custom Tag', 201 );
</script>
<?php
}
}
add_action( 'admin_print_footer_scripts', 'gelcode_add_quicktags' );
?>
Similarly, you can use this method to add your custom shortcodes buttons in WordPress editor. Like below code will add button for shortcode [box][/box]
<?php
// Add New Custom Quicktag button
function gelcode_add_quicktags() {
if (wp_script_is('quicktags')) {
?>
<script type="text/javascript">
QTags.addButton( 'eg_gelcode', 'GelCode', '', ' ', 'GelCode', 'My New custom Tag', 201 );
</script>
<?php
}
}
add_action( 'admin_print_footer_scripts', 'gelcode_add_quicktags' );
?>
Hope this article helped you.
Tutorial Category