wp_trash_comment: move a comment to Trash
Moves a comment out of sight without destroying it.
Arguments
| Argument | Required | Meaning |
|---|---|---|
comment_id |
Yes | The comment |
dry_run |
No | Report without writing |
Permissions
Allow content writes open, and moderate_comments.
The right tool for unwanted but genuine
Use this when a comment should not be on the site but is not spam:
- off-topic but written in good faith;
- abusive or offensive;
- containing personal data the author should not have posted publicly;
- a duplicate;
- a genuine complaint you want to handle privately.
For actual spam, use wp_spam_comment instead, so the filter learns something.
The distinction matters both ways. Marking a real person's message as spam can affect them beyond your site; trashing spam teaches your filter nothing.
It is reversible
The comment moves to Comments → Trash and can be restored from the WordPress admin until the trash is emptied.
That makes it the appropriate default whenever you want something gone and are not certain it must be destroyed. Between trash and wp_delete_comment, prefer this one.
Personal data is a case for deletion, not trash
One exception worth stating: if a comment must be removed because it contains personal data someone has asked you to erase, trashing is not enough. The content remains in the database.
That is a deliberate, documented decision to make under your own procedure — not something to delegate. See wp_delete_comment.
Trash by ID
Trash comments 4430 and 4431.
As with every comment action, name IDs rather than a criterion. "Trash the off-topic ones" asks the assistant to judge what is on-topic for your site.
What it returns
The comment ID and its new status.
The dry run
Reports the ID and the action. It does not return the comment content, so read the comment first if you are acting on someone else's summary of it.
After trashing
- The comment disappears from the post immediately.
- Purge the cache if comment counts appear on the site.
- The trash accumulates until emptied from the WordPress admin.
Common problems
| Symptom | Cause |
|---|---|
| The write is refused | Content write gate closed |
pom_ai_mcp_forbidden |
No moderate_comments |
| The comment still shows | Cache not purged |
| It was actually spam | Nothing breaks, but your filter learned nothing |
| The content is still in the database | Correct; trash is not deletion |
Related
wp_spam_comment— for spamwp_delete_comment— when it must be gone- Review and moderate comments