WP CLI说明文档

wp scaffold cpt

命令概述

此命令是 wp scaffold post-type 的别名,用于快速生成自定义文章类型(Custom Post Type)的注册代码。

适合在开发主题或插件时,需要快速创建并注册自定义文章类型的场景。

参数列表

参数 说明
<slug> 文章类型的内部名称。
[--label=<label>] 用于翻译更新消息的文本。
[--textdomain=<textdomain>] 用于标签的文本域。
[--dashicon=<dashicon>] 菜单中使用的 Dashicon。
[--theme] 在活动主题目录中创建文件,而不是输出到 STDOUT。使用 --theme=<theme> 指定主题。
[--plugin=<plugin>] 在给定插件目录中创建文件,而不是输出到 STDOUT。
[--raw] 仅生成 register_post_type() 调用,不包含其他内容。
[--force] 覆盖已存在的文件。

常用示例

为主题生成电影文章类型

$ wp scaffold post-type movie --label=Movie --theme=simple-life