Comments widget
The complete guide to the WidgetCore Comments widget — comment list and form for the current post, optional fields, required name and email, field order, pagination, avatars, shortcode and styling.
The Comments widget shows the current post's comment list and the comment form in one widget. Saving, spam checks, manual approval and notification emails stay the job of WordPress itself; the widget only gives you control over the look, the layout and the form fields. It needs no other plugin, ships no JavaScript of its own and creates no page or option in the dashboard.
| Item | Value |
|---|---|
| Widget name | wgcr-comments |
| Panel title | Comments |
| Category | WidgetCore Widgets (wgcr) |
| Shortcode | [wgcr_comments] |
| Style | wgcr-comments (no script) |
| Root class | .wgcr-comments |
Quick start
Drag the widget
On a single-post template (or any page that needs comments) drop “Comments” from the “WidgetCore Widgets” category.
Choose the fields
In the “Fields” section turn name, email, website and the save-in-browser checkbox on or off and translate the labels.
Set the look
In the Style tab change the colours, borders, spacing and typography of each part.
Try it on the site
Send a test comment; instant publishing or manual approval is decided by Settings → Discussion in WordPress.
The “Comment form” section
| Control | ID | Type | Default | Notes |
|---|---|---|---|---|
| Show form | form | Switcher | On | Off means list only; reply links are hidden too |
| Form title | title | Text | “Leave a comment” | Empty hides the title visually but keeps it for screen readers |
| Form title tag | title_tag | Select | h3 | h2, h3, h4, h5 or div |
| Note above the fields | note_before | Textarea | Empty | Simple, safe HTML (links, bold, …) |
| Note below the fields | note_after | Textarea | Empty | Same as above |
| Submit button text | submit | Text | “Post comment” | |
| Cancel reply text | cancel | Text | “Cancel reply” | The link that appears beside the form title while replying to a comment |
| Logged-in users only | login_only | Switcher | Off | Guests see a login message instead of the form |
The “Fields” section
| Control | ID | Default | Notes |
|---|---|---|---|
| Name, email and website layout | fields_layout | Side by side (row) | “Side by side” (row) or “Stacked” (stack); always stacked on narrow screens |
| Show field | author, email, url, cookies | On | Every field can be removed on its own |
| Required | author_required, email_required | On | Name and email; a hidden field is automatically optional |
| Label | author_label, email_label, url_label, cookies_label, comment_label | “Name”, “Email”, “Website”, “Your comment” and the checkbox text | Leaving it empty restores the default label |
| Placeholder | author_ph, email_ph, url_ph, comment_ph | Empty | |
| Display order | order_comment, order_author, order_email, order_url, order_cookies | 1, 2, 3, 4, 5 | A number from 1 to 9; the smaller comes first |
| Comment text rows | rows | 6 | 3 to 15 |
- The comment text cannot be removed or made optional.
- Website is always optional.
- The “save in browser” checkbox only appears when WordPress' own option for it (Settings → Discussion) is on; the control can only turn it off or change its text.
- Logged-in users do not see the name, email, website or checkbox fields; they get “Logged in as …” with profile and log-out links instead; the text and the links are editable in the “Messages” section.
- The field order is changed in the HTML itself, so the Tab key order always matches the visual order.
How required fields work
Every form sends a signed hidden field that tells WordPress whether name and email are required in this form. Without that field WordPress behaves exactly as its own settings say. As a result:
- You can make name and email optional even when WordPress requires them (for this form only).
- You can make email required even when WordPress does not.
- If an email is entered, its format must be valid.
- A direct post to WordPress' core endpoint (for example by a bot) without this field is checked against the WordPress settings; the widget does not close that path.
The “Comments list” section
| Control | ID | Type | Default | Notes |
|---|---|---|---|---|
| Show list | list | Switcher | On | |
| List title | list_title | Text | “Comments” | Empty = no title and no counter |
| List title tag | list_title_tag | Select | h2 | h2 to h5 or div |
| Show comment count | show_count | Switcher | On | The number next to the title |
| Comments per page (0 = follow WordPress) | per_page | Number | 0 | 0 to 100 |
| List order | order | Select | “Follow WordPress settings” (wp) | wp, “Oldest first” (asc) or “Newest first” (desc) |
| Avatar | avatar | Select | “Follow WordPress settings” (wp) | wp, yes (always) or “Hide” (no) |
| Avatar size | avatar_size | Number | 48 | 16 to 128 px |
| Show date | date | Switcher | On | |
| Show reply link | reply | Switcher | On | Only when threaded replies are on in WordPress |
| Reply link text | reply_text | Text | “Reply” |
- Threading, reply depth, pagination and the default order are decided by WordPress (Settings → Discussion); “Comments per page” and “List order” let this widget override them for itself.
- Pagination prints “Previous”, “Next” and page numbers; the current page is announced to screen readers.
- An unapproved comment is visible only to its own author, with the “Your comment is awaiting moderation.” message.
- With the avatar set to “follow WordPress”, the widget respects WordPress turning avatars off.
The “Messages” section
| Control | ID | Default |
|---|---|---|
| Empty list message | empty_text | “No comments have been posted yet.” |
| Awaiting moderation message | pending_text | “Your comment is awaiting moderation.” |
| Comments closed message | closed_text | “Comments are closed for this post.” |
| Login required message | login_text | “You must be logged in to post a comment.” |
| Show logged-in user text | loggedin_show | On |
| Logged-in user text | loggedin_text | “Logged in as {name}.” |
| Show edit profile link | loggedin_profile | On |
| Edit profile link text | loggedin_profile_text | “Edit profile” |
| Show log out link | loggedin_logout | On |
| Log out link text | loggedin_logout_text | “Log out” |
The logged-in user text is shown only to logged-in users and only when the form is shown. Write {name} where the user's display name should appear; without it no name is printed. HTML in the text is removed. Turning loggedin_show off removes only this line and keeps the form. It has its own “Logged-in user text” section in the Style tab.
Behaviour in different situations
| Situation | Output |
|---|---|
| Comments open | List and form |
| Comments closed | The list stays; the message “Comments are closed for this post.” replaces the form |
| Login required and the visitor is a guest | The login message with a login link, no form |
| Password-protected post | Nothing is shown |
| Private post or draft | Only for someone allowed to see it |
| A post type without comments | Nothing is shown |
Shortcode
[wgcr_comments]
[wgcr_comments form="no" list_title="Reader comments" avatar="no"]
[wgcr_comments list="no" title="Write your comment" email_required="no" rows="4"]
[wgcr_comments login_only="yes" login_text="Log in to comment"]
- Every attribute uses the same ID as the tables above (for example
author="no",per_page="10",order="desc"). Show/required values areyesandno. - One extra attribute,
post: the ID of another post; it defaults to the current post. - An invalid value silently falls back to the default.
- The Style tab options exist only in the widget; the shortcode uses the default look. Change it with custom CSS and the classes below.
The Style tab
Every style section is written without !important and affects only this widget.
All size controls (width, padding, margins, gaps, radius) have a device switcher and Normal/Hover tabs — see Responsive sizes and hover.
| Section | What you change |
|---|---|
| Layout | Max width, Widget alignment, Gap between list and form |
| List title | Color, Typography, Counter color, Gap to the list |
| Form title | Color, Typography |
| Form card | Background, Border (type, width and color), Border radius, Shadow, Padding |
| Labels | Color, Typography, Required asterisk color |
| Fields | Normal: Text color, Background, Placeholder color, Border (type, width and color); Focus: Background, Border color, Shadow; Typography, Border radius, Padding, Gap between fields |
| Save-in-browser checkbox | Color, Typography |
| Form notes | Color, Typography |
| Submit button | Normal: Text color, Background, Border color; Hover: Text color, Background, Border color; Typography, Border radius, Padding, Shadow |
| Comment card | Background, Border (type, width and color), Border radius, Shadow, Padding, Gap between comments, Reply indent and spacing (a four-side margin of the replies list relative to the parent card: top is the distance from the parent comment, left/right is the indent; it can differ per device) |
| Avatar | Border radius (each corner), Border (type, width and color), Avatar width (16 to 200 px, em or rem; the image stays square), Distance from the comment card (outer margin, four sides) |
| Author name | Color, Typography, Distance from the avatar (outer margin of the name, four sides) |
| Date | Color, Typography, Distance from the avatar (outer margin of the date, four sides) |
| Comment text | Color, Typography |
| Reply link | Normal: Color, Background; Hover: Color, Background; Typography, Border radius, Padding |
| Pagination | Typography, Color, Background, Hover color, Current page color, Current page background, Border radius |
| Messages | Color, Background, Typography, Border radius, Padding, Awaiting moderation message color |
| Logged-in user text | Text color, Typography, Link color, Link hover color, Link typography, Background, Border, Border radius, Shadow, Padding, Outer spacing |
The default colours were chosen for sufficient (AA) contrast. If you change them, check the text/background contrast yourself.
HTML structure and classes
| Class | Role |
|---|---|
.wgcr-comments | Root; .wgcr-comments--fields-row for the side-by-side layout |
.wgcr-comments-listwrap | The list section |
.wgcr-comments-anchor | An empty element that carries id="comments" (first instance only) so theme rules such as #comments .comment .avatar can never override the widget's style controls |
.wgcr-comments-title and .wgcr-comments-count | Title and counter |
.wgcr-comments-list | The ol list; replies live in .children, inside their parent's card |
.wgcr-comment | Each comment card (an article that also holds its replies), with the .wgcr-comment-body wrapper (its id is where the reply form opens), .wgcr-comment-head, .wgcr-comment-author, .wgcr-comment-date, .wgcr-comment-text, .wgcr-comment-reply |
.wgcr-comments-pagination | The pagination nav; .wgcr-comments-page and .is-current |
.wgcr-comments-respond | The form card; .wgcr-comments-form, .wgcr-comments-field, .wgcr-comments-input, .wgcr-comments-submit |
.wgcr-comments-notice, .wgcr-comments-pending and .wgcr-comments-loggedin | Messages, and the logged-in user text |
Accessibility
- Every field has a real
label, and required fields are announced withrequiredandaria-required; the required asterisk is hidden from screen readers. - The submit button is a real
button, and the Tab order matches the visual order. - The pagination navigation has an
aria-labeland the current page hasaria-current="page". - The focus ring is drawn for
:focus-visible; forced-colors mode andprefers-reduced-motionare supported. - The layout uses CSS logical properties, so it works in Persian (right-to-left) and English (left-to-right).
Troubleshooting
| Problem | Likely cause | Fix |
|---|---|---|
| The widget shows nothing | The post is password-protected or private, its type has no comments, or the widget is outside a post | Place it in a single-post template; give post in the shortcode |
| The theme's form or list shows up as well | The theme's comment area prints for a post the widget printed nothing for (the widget points to another post, the post is password-protected, or the widget sits in another post), or the page is an old cached copy | Put the widget in this post's own content and leave post empty; clear the cache |
| The second form is missing | A page has only one form | Keep one form per page; give the other instances form="no" |
| “Please fill in the required fields.” | A required field is empty or the email is malformed | Fill it in, or turn its required switch off |
| Guests cannot comment | WordPress or “Logged-in users only” requires login | Check Settings → Discussion |
| Making name or email optional has no effect | An old cached copy of the page, or the form is submitted from elsewhere | Clear the cache |
| A comment is not visible after sending | Manual approval or WordPress' disallowed list | Settings → Discussion; a guest sees it as “awaiting moderation” for ten minutes after sending (or longer if the save-in-browser checkbox was ticked) |
| The avatar image loads from another site | WordPress' Gravatar behaviour | Set “Avatar” to “Hide” |
Related guides: Shortcode, Accessibility, Troubleshooting.