WP CLI说明文档

wp comment generate

命令概述

用于生成指定数量的新评论,并填充虚拟数据。

适合在测试或开发环境中快速创建评论数据,支持指定所属文章和输出格式。

参数列表

参数说明
--count=<number>要生成的评论数量。默认:100
--post_id=<post-id>将评论分配给特定文章。
--format=<format>以特定格式渲染输出。默认:progress;选项:progress、ids

常用示例

为指定文章生成评论

$ wp comment generate --format=ids --count=3 --post_id=123
138 139 140

为每条生成的评论添加自定义字段

$ wp comment generate --format=ids --count=3 | xargs -d ' ' -I % wp comment meta add % foo bar
Success: Added custom field.
Success: Added custom field.
Success: Added custom field.