# wp comment

Aide:

```bash
$ wp help comment
```

```bash
NAME

  wp comment

DESCRIPTION

  Creates, updates, deletes, and moderates comments.

SYNOPSIS

  wp comment <command>

SUBCOMMANDS

  approve        Approves a comment.
  count          Counts comments, on whole blog or on a given post.
  create         Creates a new comment.
  delete         Deletes a comment.
  exists         Verifies whether a comment exists.
  generate       Generates some number of new dummy comments.
  get            Gets the data of a single comment.
  list           Gets a list of comments.
  meta           Adds, updates, deletes, and lists comment custom fields.
  recount        Recalculates the comment_count value for one or more posts.
  spam           Marks a comment as spam.
  status         Gets the status of a comment.
  trash          Trashes a comment.
  unapprove      Unapproves a comment.
  unspam         Unmarks a comment as spam.
  untrash        Untrashes a comment.
  update         Updates one or more comments.
```

Affiche le nombre de commentaires:

```bash
$ wp comment count
approved:        2
spam:            0
trash:           0
post-trashed:    0
all:             2
moderated:       0
total_comments:  2
```

Liste des commentaires (approuvés ou non):

```bash
$ wp comment list
+------------+-----------------+---------------------+------------------+---------------------------+-------------------------+
| comment_ID | comment_post_ID | comment_date        | comment_approved | comment_author            | comment_author_email    |
+------------+-----------------+---------------------+------------------+---------------------------+-------------------------+
| 5          | 209             | 2018-08-14 08:00:18 | 1                | bruno                     | bruno@clicclac.info     |
| 4          | 209             | 2018-08-14 07:59:55 | 0                | bruno                     | bruno@clicclac.info     |
| 1          | 1               | 2017-01-29 09:19:42 | 1                | Un commentateur WordPress | wapuu@wordpress.example |
+------------+-----------------+---------------------+------------------+---------------------------+-------------------------+
```

Liste de tous les commentaires (y compris spam, supprimés, post supprimés):

```bash
$ wp comment list --status=all,spam,trash,post-trashed
+------------+-----------------+---------------------+------------------+---------------------------+-------------------------+
| comment_ID | comment_post_ID | comment_date        | comment_approved | comment_author            | comment_author_email    |
+------------+-----------------+---------------------+------------------+---------------------------+-------------------------+
| 8          | 210             | 2018-08-14 08:11:08 | post-trashed     | bruno                     | bruno@clicclac.info     |
| 7          | 209             | 2018-08-14 08:01:02 | 1                | bruno                     | bruno@clicclac.info     |
| 6          | 209             | 2018-08-14 08:00:46 | trash            | bruno                     | bruno@clicclac.info     |
| 5          | 209             | 2018-08-14 08:00:18 | 1                | bruno                     | bruno@clicclac.info     |
| 4          | 209             | 2018-08-14 07:59:55 | 0                | bruno                     | bruno@clicclac.info     |
| 3          | 209             | 2018-08-14 07:59:27 | 1                | bruno                     | bruno@clicclac.info     |
| 2          | 57              | 2017-01-29 20:20:06 | spam             | bruno                     | bruno@clicclac.info     |
| 1          | 1               | 2017-01-29 09:19:42 | 1                | Un commentateur WordPress | wapuu@wordpress.example |
+------------+-----------------+---------------------+------------------+---------------------------+-------------------------+
```

Déclarer un commentaire en SPAM:

```bash
$ wp comment spam 2
Success: Marked as spam comment 2.
```

Liste des SPAMs:

```bash
$ wp comment list --status=spam
+------------+-----------------+---------------------+------------------+----------------+----------------------+
| comment_ID | comment_post_ID | comment_date        | comment_approved | comment_author | comment_author_email |
+------------+-----------------+---------------------+------------------+----------------+----------------------+
| 2          | 57              | 2017-01-29 20:20:06 | spam             | bruno          | bruno@clicclac.info  |
+------------+-----------------+---------------------+------------------+----------------+----------------------+
```

Ne plus déclarer un commentaire en SPAM:

```bash
$ wp comment unspam 2
Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
Success: Unspammed comment 2.
```

Effacer le SPAM:

```bash
$ wp comment delete $(wp comment list --status=spam --format=ids)
Success: Trashed comment 2.
```

Effacer les commentaires supprimés et post supprimés:

```bash
$ wp comment delete $(wp comment list --status=trash,post-trashed --format=ids)
Success: Trashed comment 8.
Success: Deleted comment 6.
```

Liste des trackback:

```bash
$ wp comment list --type=trackback --format=ids
```

Liste des Pingback:

```bash
$ wp comment list --type=pingback --format=ids
```



