WP CLI说明文档

wp comment list

命令概述

根据WP_Comment_Query()支持的所有参数显示评论列表。

适合在需要查看、筛选或导出WordPress评论时使用,支持按状态、文章ID等条件过滤。

参数列表

参数 说明
--<field>=<value> 一个或多个传递给WP_Comment_Query的参数。
--field=<field> 打印每条评论的单个字段值。
--fields=<fields> 将输出限制为特定对象字段。
--format=<format> 以特定格式渲染输出。默认:table。选项:table、ids、csv、json、count、yaml。

常用示例

列出评论ID

$ wp comment list --field=ID

列出某篇文章的评论

$ wp comment list --post_id=1 --fields=ID,comment_date,comment_author

列出已批准的评论

$ wp comment list --number=3 --status=approve --fields=ID,comment_date,comment_author

列出未批准的评论

$ wp comment list --number=3 --status=hold --fields=ID,comment_date,comment_author

列出标记为垃圾评论的评论

$ wp comment list --status=spam --fields=ID,comment_date,comment_author

列出回收站中的评论

$ wp comment list --status=trash --fields=ID,comment_date,comment_author