What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Add comment-form Quicktags on a classic WordPress theme by loading WordPress’s built-in Quicktags script on pages with open comments, then initializing it for the comment textarea. Keep the textarea’s id="comment" and name="comment" intact. If your site uses the block-based Post Comments Form, the classic PHP hooks may not control its output.
Before you add the toolbar
Quicktags provides buttons for the Text (HTML) editor, including controls such as bold, italic, link, blockquote, code, and close-tag. WordPress describes the API as a way to add buttons to the Text (HTML) mode of the Classic editor: Quicktags – Common APIs Handbook.
The steps below apply to a classic theme that outputs its comment form through comment_form(). The function outputs a complete commenting form for use within a template, and its hooks and filters provide ways to customize that form: comment_form() – Function. Use a small site-specific plugin for code you want to keep if you change themes, or put it in your active theme’s PHP customization layer.
Add Quicktags to a classic comment form
- Enqueue the Quicktags script. Add this PHP code to your site plugin or active theme’s customization file. It loads the script only on singular pages where comments are open.
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' ); - Initialize the toolbar for the comment textarea. Add this alongside the enqueue code:
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' ); - Save and check a post with comments enabled. Open its comment form and confirm the toolbar appears. Test a button with a comment draft before relying on it; the toolbar inserts markup into the comment text.
The comment_form_after_fields action runs after the comment fields, excluding the textarea. The code works when the form’s placement makes that action a suitable place for Quicktags initialization. If your theme positions or builds the comment field differently, use the comment_form_field_comment filter or pass a custom comment_field argument to comment_form(). The function reference documents the available hooks and arguments.
#1 Best Overall
Keep the comment field’s expected attributes
If you replace the textarea markup using a filter or a custom comment_form() argument, preserve its id="comment" and name="comment" attributes. The Quicktags instance targets the ID, while the name identifies the comment body submitted with the form. WordPress’s default comment field uses these attributes; see the comment_form() reference and the comment_form_field_comment hook reference.
Register a custom Quicktags button
To add a button beyond the built-in set, register it in JavaScript after Quicktags is available. For example, this button wraps selected text in a <mark> element:
QTags.addButton(
'my_mark',
'mark',
'<mark>',
'</mark>',
'',
'Insert highlighted text',
25,
'comment'
);
The arguments identify the button, its visible label, opening and closing tags, an optional title, priority, and optionally the editor instance. The ID must be unique. The final 'comment' argument targets the comment editor; the official Quicktags API reference documents the method and built-in button IDs.
Load your custom JavaScript on the front end after the Quicktags script, and keep the same open-comments condition if the script is only needed on comment pages. Choose tags that make sense for your site’s comment policy; a toolbar inserts markup but does not determine what markup WordPress or a security plugin will accept or preserve.
Rank #3
Classic themes and block themes use different form paths
The PHP approach above is for a classic form rendered through comment_form(). A block theme may instead render comments through the Post Comments Form block, represented in block markup as <!-- wp:post-comments-form /-->. That is a separate rendering path, so classic comment-form hooks may not be enough to place or initialize a toolbar. The Post Comments Form block reference documents the block. For a block-based form, inspect the rendered markup and use a block-aware extension or a plugin integration point that explicitly supports that form.
Quick Recap
Best Value
Choose between custom code and a plugin
| Approach | Control and maintenance | Theme compatibility | Best fit |
|---|---|---|---|
| Custom PHP and JavaScript | Direct control over buttons, labels, tags, and where assets load; requires maintaining the code and checking it when the theme or form changes. | Designed for classic forms using comment_form(); a block-based form may need a separate integration. |
Site owners who need a tailored toolbar or want it only on selected comment forms. |
| Plugin | Less code to maintain directly; available settings and button customization depend on the plugin. | Check the plugin’s description and support information for compatibility with the site’s theme and form type. | Site owners who prefer configuration to writing code. The WordPress.org listing for Simple Comment Quicktags says it adds basic Quicktag buttons to comment forms using WordPress’s built-in API. |
Common problems to check
- No toolbar appears: confirm comments are open on the page, the Quicktags script is enqueued, and the initialization targets the textarea ID
comment. - The toolbar is in the wrong place or missing on a custom form: check where the theme outputs the textarea. The after-fields action excludes the textarea; use the comment-field filter or a custom form argument if the theme’s arrangement requires it.
- Comments do not submit as expected: check that replacement markup retains both
id="comment"andname="comment". - Classic hooks have no effect in a block theme: establish whether the Post Comments Form block renders the form, then use an integration designed for that path.
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.

