Comment Form Shortcode
Insert a comment form manually using a shortcode.
sce_comment_form Shortcode
sce_comment_form ShortcodeThe sce_comment_form shortcode outputs the native WordPress comment form anywhere shortcodes are supported (Classic Editor, widgets, template content, etc.).
It mirrors WordPress’s built-in comment_form() functionality while adding control over where and how many comment forms appear, including support for multiple forms on a single page and cross-posting comments to a different post or page.
Basic Usage
[sce_comment_form]Outputs the default WordPress comment form for the current post.
Shortcode Attributes
Visibility & Display Controls
hide_secondary_comment_forms
boolean
false
Hides all other comment forms rendered after this one. Useful when multiple comment forms exist on a page.
hide_on_comment_pagination
boolean
false
Hides the comment form when viewing paginated comment pages (?cpage=2, etc.).
hide_all_comment_forms
boolean
false
Prevents any comment form from rendering (including this shortcode instance).
post
integer | null
null
The post ID the comment form should submit comments to. Defaults to the current post if not set.
Supported comment_form() Attributes
comment_form() AttributesThis shortcode also supports all standard comment_form() arguments, including but not limited to:
id_formid_submitclass_containerclass_formclass_submitname_submit
These are passed directly through to WordPress’s comment_form() function.
See comment_form for arguments. Non-array/object values can be passed straight through.
Examples
1. Basic Comment Form
Outputs the default comment form for the current post.
2. Post Comments to a Different Page or Post
Comments submitted through this form will be attached to post ID 42, regardless of where the shortcode appears.
Use case: Landing pages, sales pages, or hubs that funnel discussion to a single post.
3. Hide the Comment Form on Paginated Comment Pages
Prevents the comment form from appearing on comment pagination pages such as:
4. Allow Only One Comment Form on the Page
Ensures that only the first rendered comment form is displayed, even if:
The theme outputs a comment form
Another shortcode instance appears later
Another plugin adds a comment form
5. Hide All Comment Forms (Including Native Ones)
Suppresses all comment forms on the page.
Use case: Temporarily disabling comments on specific pages without changing global discussion settings.
6. Customize Form IDs and Classes
Useful for targeting the form with custom CSS or JavaScript.
Behavior Notes
The shortcode uses WordPress’s native
comment_form()internally, ensuring compatibility with:Core comment handling
Themes
Anti-spam plugins
Comment moderation workflows
Output buffering is used to safely capture and suppress additional comment forms when requested.
Multiple shortcode instances are supported on the same page.
When to Use This Shortcode
This shortcode is especially useful when:
You’re working on Classic Editor or shortcode-based layouts
You need multiple comment forms on a single page
You want comments submitted to a different post
You want precise control over when and where comment forms appear
Creating a block would be unnecessary or redundant
Last updated
Was this helpful?
