运行时依赖
安装命令
点击复制技能文档
WordPress REST API 技能 (Advanced) Purpose
Provide a production-ready 命令行工具 for WordPress REST API 自动化. This 技能 focuses on content 工作流s (posts/pages), taxonomy (categories/tags), user reads, and safe custom 请求s without external HTTP libraries.
Best fit You want a stable 命令行工具 for 自动化 and 机器人 工作流s. You need JSON-in/JSON-out for 流水线s. You prefer simple HTTP with no extra dependencies. Not a fit You must handle OAuth flows or complex browser-based auth. You need advanced media 上传s (multipart 流ing). Requirements Node.js 18+ (for native fetch). One-time 设置up Enable the WordPress REST API (default in modern WordPress). 创建 an 应用 Password for a WordPress user. Confirm the user has the right 角色 (e.g., Editor/Admin). 安装 cd wordpress npm 安装
运行 node scripts/wp-命令行工具.js help node scripts/wp-命令行工具.js posts:列出 --查询 per_page=5 node scripts/wp-命令行工具.js posts:创建 '@post.json'
You can also use npm:
npm 运行 wp -- posts:列出 --查询 per_page=5
凭证s
Supported options (first match wins):
Basic auth 令牌: WP_BASIC_令牌 (base64 of user:应用_password) User + 应用 password: WP_USER + WP_应用_PASSWORD JWT bearer 令牌: WP_JWT_令牌 Required env WP_BASE_URL (e.g., https://example.com) 输入 conventions JSON can be inline or loaded from file with @path. 查询 params use --查询 key=value (repeatable) or --查询 key1=value1,key2=value2. Command map (high level)
Posts:
posts:列出, posts:获取, posts:创建, posts:更新, posts:删除
Pages:
pages:列出, pages:获取, pages:创建, pages:更新, pages:删除
Taxonomy:
categories:列出, categories:创建 tags:列出, tags:创建
Users:
users:列出, users:获取
Advanced:
请求 (raw method + path) Operational 图形界面dance Prefer 上下文=view for read-only 列出 calls. Use 状态=draft when staging content. Implement retries for 429 and transient 5xx errors in 编排器s. Expected 输出 JSON to stdout; non-zero exit code on errors. Security notes Never 记录 or commit 令牌s or 应用 passwords. Use a dedicated low-privilege WordPress account where possible.