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:
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errors#1 Best Overall
<?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.
Rank #3
- 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.
Best Value
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.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Quick Recap
Verification and troubleshooting
- No toolbar appears: confirm the page is singular, comments are open, the
quicktagsscript is enqueued, and the browser console has no JavaScript errors. - Buttons appear in the wrong place: move the output from
comment_form_after_fieldsinto acomment_form_field_commentreplacement or a customcomment_fieldargument. - 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.

