WordPress Comments

Comments let your visitors talk about your posts. They are good for a community, but they also bring spam, so you have to set them up with care.

Discussion settings

Open Settings > Discussion. These are the important options and their default values:

Terminal output

$ wp option get default_comment_status
open
$ wp option get comment_moderation
0
$ wp option get comment_previously_approved
1
$ wp option get require_name_email
1
$ wp option get close_comments_for_old_posts
0
$ wp option get close_comments_days_old
14
$ wp option get thread_comments
1

OptionMeaning
default_comment_statusNew posts accept comments (open) or not (closed)
comment_moderationIf 1, every comment waits for your approval
comment_previously_approvedAuto approve the comments of people who had an approved comment before
require_name_emailCommenters must give name and email
close_comments_for_old_postsClose the comments after some days
thread_commentsAllow replies to comments (nested)

Comment status

StatusMeaning
hold (Pending)Waiting for approval, not visible
approve (Approved)Visible on the post
spamMarked as spam
trashDeleted, can be restored

Manage comments with WP-CLI

Terminal output

$ wp comment create –comment_post_ID=1 –comment_author="Riya" –comment_author_email="riya@example.com" –comment_content="Nice post, thanks!" –comment_approved=0 –comment_date="2026-02-05 12:00:00" –porcelain
2
$ wp comment list –fields=comment_ID,comment_author,comment_approved
comment_ID comment_author comment_approved
2 Riya 0
1 A WordPress Commenter 1
$ wp comment approve 2
Success: Approved comment 2.
$ wp comment spam 1
Success: Marked comment 1 as spam.
$ wp comment list –fields=comment_ID,comment_author,comment_approved
comment_ID comment_author comment_approved
2 Riya 1
$ wp comment count
approved: 1
spam: 1
trash: 0
post-trashed: 0
all: 1
moderated: 0
total_comments: 2

How to fight spam

  • Keep comment moderation on, or at least allow only previously approved commenters.
  • Use an anti spam plugin like Akismet (it comes with WordPress, but you must activate it).
  • Close the comments on old posts, and turn them off on pages where you do not need them.
  • If you do not want any comments, set default_comment_status to closed, or use a plugin to disable them.
Note: A comment form shows the name, email and website fields for guests. The email is never shown to the public, but remember that it is the personal data of your visitors, so mention it in your privacy policy. Next: WordPress Menus.

Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.