Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To add bold, italic, link, code, and quote controls to a classic WordPress comment form, load the Quicktags assets only where comments are open, then call quicktags() for the textarea whose contract is id="comment" and name="comment". Add custom controls with QTags.addButton(). The approach below works with classic PHP comment forms; block themes that use the Post Comments Form block require a block-aware integration instead.

How WordPress comment Quicktags work

WordPress’s Quicktags API creates the button bar used by the Text (HTML) editor. The API was introduced in WordPress 3.3 and exposes both the built-in controls and a JavaScript method for registering your own buttons.

Classic themes normally render comments through comment_form(), which outputs the complete form and provides actions and filters for changing its fields. The important integration point is the comment textarea: submitted text must still come from a field named comment, with the expected ID comment.

Recommended setup for a classic theme

1. Enqueue Quicktags only on relevant pages

Put this code in a small site plugin or in the active theme’s PHP customization layer:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<?php
function my_comment_quicktags_assets() {
    if ( is_singular() && comments_open() ) {
        wp_enqueue_script( 'quicktags' );
        wp_enqueue_style( 'dashicons' );
    }
}
add_action( 'wp_enqueue_scripts', 'my_comment_quicktags_assets' );

The conditions prevent front-end Quicktags assets from loading on archives, pages with closed comments, and other screens that have no usable comment form.

2. Render the toolbar for the comment editor

function my_comment_quicktags_toolbar() {
    if ( function_exists( 'quicktags' ) ) {
        quicktags( array(
            'id'      => 'comment',
            'buttons' => 'strong,em,link,block,code,close',
        ) );
    }
}
add_action( 'comment_form_after_fields', 'my_comment_quicktags_toolbar' );

The listed IDs enable common controls: bold (strong), italic (em), link (link), quotation/block markup (block), code (code), and the closing-tag control (close). Check the rendered form after adding the hook: comment_form_after_fields fires after the comment fields while excluding the textarea, so a particular theme may place the toolbar somewhere other than directly above the box.

3. Put the toolbar exactly where the textarea appears

If the action does not produce the desired order, change the comment field itself. The comment_form_field_comment filter lets you replace or wrap the textarea markup, and comment_form() accepts a custom comment_field argument. Whichever method you use, retain these attributes:

<textarea id="comment" name="comment"></textarea>

Removing or renaming either attribute can stop WordPress from receiving the comment body or prevent the Quicktags instance from attaching to the correct editor.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Alfred's Teach Yourself to Play Electronic Keyboard: Everything You Need to Know to Start Playing Now! (Teach Yourself Series)
  • Format: Book
  • Instrument: Electronic Keyboard
  • Category: Electronic Keyboard
  • Contributors: By Morton Manus, Willard A. Palmer, and Thomas Palmer
  • Pub Date: 11/1987

Adding your own Quicktag button

Register custom buttons after the Quicktags script is available. This example adds a <mark> control for highlighted text:

QTags.addButton(
  'my_mark',
  'mark',
  '<mark>',
  '</mark>',
  '',
  'Insert highlighted text',
  25,
  'comment'
);

QTags.addButton() takes a unique button ID, the visible label, opening and closing strings, an optional title, a priority, and optionally the editor instance. The final comment argument targets the comment editor rather than another Quicktags instance.

Loading the custom JavaScript

Place the call in a JavaScript file enqueued on the same singular pages as the PHP code. Guard it so it runs only when the API exists:

(function () {
  if (typeof QTags === 'undefined') {
    return;
  }

  QTags.addButton(
    'my_mark',
    'mark',
    '<mark>',
    '</mark>',
    '',
    'Insert highlighted text',
    25,
    'comment'
  );
}());

Use a unique ID for every custom control. Limit opening and closing strings to markup that your comment policy and sanitization rules permit; a button only inserts text and does not make otherwise disallowed HTML safe.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Classic PHP hooks and when to use each

Extension point Best use Important constraint
comment_form_after_fields Output a toolbar or other content around the standard fields Its position depends on the theme’s form markup and it excludes the textarea field itself.
comment_form_field_comment Replace or wrap the comment textarea Keep id="comment" and name="comment".
comment_form() with comment_field Supply complete custom textarea markup from the template The replacement still has to submit the comment body under the expected field name.

Use the least invasive option that gives the required placement. A toolbar printed by an action is easier to maintain; replacing the field gives precise control but makes theme and accessibility changes your responsibility.

Block themes need a different integration

A block theme may render comments with the Post Comments Form block, represented in templates by <!-- wp:post-comments-form /-->. That rendering path is separate from the classic PHP comment_form() path, so classic hooks may not run around the markup you see in the browser.

Inspect the block’s generated HTML and use a block-aware extension point or a plugin that explicitly supports the Post Comments Form block. Do not assume that adding comment_form_after_fields will modify every block-theme form.

Custom code or a plugin?

Choice Advantages Trade-offs
Custom PHP and JavaScript Exact control over labels, allowed tags, placement, and which forms receive the toolbar; no additional plugin settings screen. Requires maintaining hooks, assets, markup compatibility, and block-theme behavior.
Simple Comment Quicktags plugin Uses WordPress’s built-in Quicktags API and provides basic buttons without writing the integration yourself. Button selection and placement depend on the plugin; verify compatibility with your theme, WordPress version, and block-based comment form.

Choose custom code when you need a tightly restricted button set or the toolbar only on selected forms. Choose a plugin when settings-based installation matters more than exact markup control.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Verification and troubleshooting

  • No toolbar appears: confirm the page is singular, comments are open, the quicktags script is enqueued, and the browser console has no JavaScript errors.
  • Buttons appear in the wrong place: move the output from comment_form_after_fields into a comment_form_field_comment replacement or a custom comment_field argument.
  • Clicking a button does nothing: inspect the textarea and confirm its ID is exactly comment; ensure the custom script runs after Quicktags is loaded.
  • Comments submit without text: check that the textarea still has name="comment" and that no duplicate field with the same name is being submitted.
  • The hooks never fire: determine whether the template uses the Post Comments Form block instead of comment_form(), then use a block-aware integration or compatible plugin.
  • Markup is stripped after submission: Quicktags does not override WordPress’s sanitization or the site’s comment policy. Allow only tags your moderation and sanitization setup is designed to handle.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.