wp-rest-api by wordpress/agent-skills
npx skills add https://github.com/wordpress/agent-skills --skill wp-rest-api在以下情况下使用此技能:
my-plugin/v1)和路由。node skills/wp-project-triage/scripts/detect_wp_project.mjsregister_rest_routeWP_REST_Controller广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
rest_api_initshow_in_rest, rest_base, rest_controller_class如果这是一个完整的站点仓库,请在修改代码前选择特定的插件/主题。
wp/v2 中公开 CPT/分类法:
show_in_rest => true + rest_base。rest_controller_class。references/custom-content-types.md。rest_api_init 上使用 register_rest_route()。WP_REST_Controller 的子类)。references/routes-and-endpoints.md 和 references/schema.md。vendor/v1;除非是核心功能,否则避免使用 wp/*。permission_callback(对于公共端点使用 __return_true)。WP_REST_Server::READABLE/CREATABLE/EDITABLE/DELETABLE 常量。rest_ensure_response() 或 WP_REST_Response 返回数据。status 的 WP_Error 返回错误。阅读 references/routes-and-endpoints.md。
type、default、required、validate_callback、sanitize_callback 定义 args。rest_validate_value_from_schema 然后 rest_sanitize_value_from_schema 进行 JSON 模式验证。$_GET/$_POST;使用 WP_REST_Request。阅读 references/schema.md。
register_rest_field;对于元数据使用带有 show_in_rest 的 register_meta。object/array 类型的元数据,在 show_in_rest.schema 中定义模式。?context=edit 以访问 content.raw(需要认证)。配合使用 _fields=content.raw 以保持响应较小。WP_REST_Response::add_link() 添加相关资源链接。阅读 references/responses-and-fields.md。
X-WP-Nonce(action 为 wp_rest)。permission_callback 中使用能力检查(授权),而不仅仅是“已登录”。阅读 references/authentication.md。
Link 头或 <link rel="https://api.w.org/">)。_fields、_embed、_method、_envelope、分页头。per_page 上限为 100。阅读 references/discovery-and-params.md。
/wp-json/ 索引包含你的命名空间。OPTIONS 请求返回模式(如果已提供)。show_in_rest 为 true 时,CPT/分类法路由出现在 wp/v2 下。rest_api_init 未触发、路由拼写错误或固定链接未开启(使用 ?rest_route=)。permission_callback 过于严格。permission_callback 导致 _doing_it_wrong:添加它(如果是公共端点则使用 __return_true)。args 模式或验证回调。show_in_rest 为 false、元数据未注册,或 CPT 缺少 custom-fields 支持。如果版本支持或行为不明确,在发明新模式之前,请查阅 REST API 手册和核心文档。
每周安装量
645
仓库
GitHub 星标数
972
首次出现
2026年2月1日
安全审计
安装于
codex508
opencode501
gemini-cli496
github-copilot491
kimi-cli480
amp478
Use this skill when you need to:
my-plugin/v1) and routes.node skills/wp-project-triage/scripts/detect_wp_project.mjsregister_rest_routeWP_REST_Controllerrest_api_initshow_in_rest, rest_base, rest_controller_classIf this is a full site repo, pick the specific plugin/theme before changing code.
wp/v2:
show_in_rest => true + rest_base if needed.rest_controller_class.references/custom-content-types.md.register_rest_route() on rest_api_init.WP_REST_Controller subclass) for anything non-trivial.references/routes-and-endpoints.md and .vendor/v1; avoid wp/* unless core.permission_callback (use __return_true for public endpoints).WP_REST_Server::READABLE/CREATABLE/EDITABLE/DELETABLE constants.rest_ensure_response() or WP_REST_Response.WP_Error with an explicit status.Read references/routes-and-endpoints.md.
args with type, default, required, validate_callback, sanitize_callback.rest_validate_value_from_schema then rest_sanitize_value_from_schema.$_GET/$_POST directly inside endpoints; use WP_REST_Request.Read references/schema.md.
register_rest_field for computed fields; register_meta with show_in_rest for meta.object/array meta, define schema in show_in_rest.schema.?context=edit to access content.raw (auth required). Pair with _fields=content.raw to keep responses small.WP_REST_Response::add_link().Read references/responses-and-fields.md.
X-WP-Nonce (action wp_rest).permission_callback (authorization), not just “logged in”.Read references/authentication.md.
Link header or <link rel="https://api.w.org/">)._fields, _embed, _method, _envelope, pagination headers.per_page is capped at 100.Read references/discovery-and-params.md.
/wp-json/ index includes your namespace.OPTIONS on your route returns schema (when provided).wp/v2 when show_in_rest is true.rest_api_init not firing, route typo, or permalinks off (use ?rest_route=).permission_callback too strict._doing_it_wrong for missing permission_callback: add it (use __return_true if public).args schema or validation callbacks.show_in_rest false, meta not registered, or CPT lacks custom-fields support.If version support or behavior is unclear, consult the REST API Handbook and core docs before inventing patterns.
Weekly Installs
645
Repository
GitHub Stars
972
First Seen
Feb 1, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex508
opencode501
gemini-cli496
github-copilot491
kimi-cli480
amp478
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
136,300 周安装
AI代码审查专家 | 自动检测安全漏洞、性能问题与代码质量
1,800 周安装
数据分析师技能:精通SQL、Python pandas和统计分析的AI助手
1,900 周安装
Flutter原生视图与网页嵌入指南:Android/iOS平台视图集成与Web应用嵌入
2,200 周安装
Next.js App Router 基础教程:从 Pages Router 迁移到现代路由架构
1,800 周安装
Rust可变性指南:理解&mut、Cell、RefCell、Mutex选择与反模式
613 周安装
Stitch Design Taste - 生成Google Stitch语义化设计系统DESIGN.md文件,优化AI界面生成
2,700 周安装
references/schema.md