WP CLI说明文档

命令概述

用于管理 WordPress 分类法中的术语(term),支持创建、更新、删除、查询以及重建计数等操作。

适合在需要批量管理分类、标签或自定义分类法时使用。

参数列表

参数 说明
--description 术语的描述。
--format 输出格式,如 json。
--fields 要返回的字段列表。
--field 仅返回单个字段的值。
--include 要包含的术语 ID。
--name 术语的新名称。

常用示例

创建新术语

$ wp term create category Apple --description="一种水果"

获取术语详情

$ wp term get category 199 --format=json --fields=term_id,name,slug,count

更新现有术语

$ wp term update category 15 --name=Apple

获取术语的 URL

$ wp term list post_tag --include=123 --field=url

删除分类术语

$ wp term delete category 15

重建术语计数

$ wp term recount category post_tag