wp comment

in this article we are going to learn how to use WP comment command.

We can use WP comment CLI command to manage comments from our wordpress website.

Below is the list of CLI commands which we can use to perform add, delete, update etc operations on comments


# Create a new comment.
$ wp comment create --comment_post_ID=15 --comment_content="hello blog" --comment_author="wp-cli"
Success: Created comment 932.

# Update an existing comment.
$ wp comment update 123 --comment_author='That Guy'
Success: Updated comment 123.

# Delete an existing comment.
$ wp comment delete 1337 --force
Success: Deleted comment 1337.

# Delete all spam comments.
$ wp comment delete $(wp comment list --status=spam --format=ids)
Success: Deleted comment 264.
Success: Deleted comment 262.


Name Description
wp comment approve

Approves a comment.

wp comment count

Counts comments, on whole blog or on a given post.

wp comment create

Creates a new comment.

wp comment delete

Deletes a comment.

wp comment exists

Verifies whether a comment exists.

wp comment generate

Generates some number of new dummy comments.

wp comment get

Gets the data of a single comment.

wp comment list

Gets a list of comments.

wp comment meta

Adds, updates, deletes, and lists comment custom fields.

wp comment recount

Recalculates the comment_count value for one or more posts.

wp comment spam

Marks a comment as spam.

wp comment status

Gets the status of a comment.

wp comment trash

Trashes a comment.

wp comment unapprove

Unapproves a comment.

wp comment unspam

Unmarks a comment as spam.

wp comment untrash

Untrashes a comment.

wp comment update

Updates one or more comments.