wp_delete_comment
Delete a WordPress comment by ID. Trashes by default (recoverable); use force=true to permanently remove. Prefer moderation for spam. Dry-run by default.
Instructions
Delete a comment: force=true is PERMANENT; the default trashes it (recoverable).
By default the comment goes to the trash and can be restored from wp-admin -
that comes back as action: "trashed", which is a success. With force=true it is
erased from the database and nothing here can bring it back. Prefer
wp_moderate_comment with 'spam' for spam: it trains the filters, where a delete
teaches them nothing. comment_id comes from wp_list_comments. DEFAULTS TO
dry_run=true (returns a preview stating which of the two outcomes you would get;
deletes nothing). Pass dry_run=false to apply. Requires the REST transport. Prod
writes require allow_prod=true.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| force | No | ||
| dry_run | No | ||
| install | Yes | ||
| allow_prod | No | ||
| comment_id | Yes |