REST API 文档

💡 云策文档标注

概述

本文档介绍了 WordPress REST API 中状态(Statuses)的架构和端点。它定义了状态记录的字段,并提供了检索状态列表或单个状态的 API 方法。

关键要点

  • 状态架构包含多个字段,如 name、slug、public、queryable 等,每个字段有 JSON 数据类型、只读属性和上下文限制。
  • 支持通过 GET /wp/v2/statuses 端点检索所有状态列表,使用 context 参数控制响应字段。
  • 支持通过 GET /wp/v2/statuses/<status> 端点检索特定状态,需提供状态标识符和可选的 context 参数。

代码示例

GET /wp/v2/statuses
$ curl https://example.com/wp-json/wp/v2/statuses

GET /wp/v2/statuses/<status>
$ curl https://example.com/wp-json/wp/v2/statuses/<status>

注意事项

  • 字段响应受 _filter 查询参数或特定上下文影响,默认情况下返回所有定义字段。
  • context 参数可选值为 view、embed 或 edit,默认值为 view,用于确定响应中包含的字段。

📄 原文内容

Schema

The schema defines all the fields that exist within a status record. Any response from these endpoints can be expected to contain the fields below unless the `_filter` query parameter is used or the schema field only appears in a specific context.

name The title for the status.

JSON data type: string

Read only

Context: embed, view, edit

private Whether posts with this status should be private.

JSON data type: boolean

Read only

Context: edit

protected Whether posts with this status should be protected.

JSON data type: boolean

Read only

Context: edit

public Whether posts of this status should be shown in the front end of the site.

JSON data type: boolean

Read only

Context: view, edit

queryable Whether posts with this status should be publicly-queryable.

JSON data type: boolean

Read only

Context: view, edit

show_in_list Whether to include posts in the edit listing for their post type.

JSON data type: boolean

Read only

Context: edit

slug An alphanumeric identifier for the status.

JSON data type: string

Read only

Context: embed, view, edit

date_floating Whether posts of this status may have floating published dates.

JSON data type: boolean

Read only

Context: view, edit

Retrieve a Status

Definition & Example Request

GET /wp/v2/statuses

Query this endpoint to retrieve a specific status record.

$ curl https://example.com/wp-json/wp/v2/statuses

Arguments

context Scope under which the request is made; determines fields present in response.

Default: view

One of: view, embed, edit

Retrieve a Status

Definition & Example Request

GET /wp/v2/statuses/<status>

Query this endpoint to retrieve a specific status record.

$ curl https://example.com/wp-json/wp/v2/statuses/<status>

Arguments

status An alphanumeric identifier for the status.
context Scope under which the request is made; determines fields present in response.

Default: view

One of: view, embed, edit