本文档介绍了 WordPress REST API 中 Types 端点的 schema 定义和检索方法。Schema 定义了文章类型记录的字段,包括 capabilities、description、hierarchical 等,这些字段在响应中默认出现,除非使用 `_filter` 参数或特定上下文限制。文档还提供了检索所有类型和特定类型的 API 端点、示例请求和参数说明。
The schema defines all the fields that exist within a type 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.
capabilities
|
All capabilities used by the post type.
JSON data type: object Read only Context: |
description
|
A human-readable description of the post type.
JSON data type: string Read only Context: |
hierarchical
|
Whether or not the post type should have children.
JSON data type: boolean Read only Context: |
viewable
|
Whether or not the post type can be viewed.
JSON data type: boolean Read only Context: |
labels
|
Human-readable labels for the post type for various contexts.
JSON data type: object Read only Context: |
name
|
The title for the post type.
JSON data type: string Read only Context: |
slug
|
An alphanumeric identifier for the post type.
JSON data type: string Read only Context: |
supports
|
All features, supported by the post type.
JSON data type: object Read only Context: |
has_archive
|
If the value is a string, the value will be used as the archive slug. If the value is false the post type has no archive.
JSON data type: string or boolean Read only Context: |
taxonomies
|
Taxonomies associated with post type.
JSON data type: array Read only Context: |
rest_base
|
REST base route for the post type.
JSON data type: string Read only Context: |
rest_namespace
|
REST route's namespace for the post type.
JSON data type: string Read only Context: |
visibility
|
The visibility settings for the post type.
JSON data type: object Read only Context: |
icon
|
The icon for the post type.
JSON data type: string or null Read only Context: |
GET /wp/v2/types
Query this endpoint to retrieve a specific type record.
$ curl https://example.com/wp-json/wp/v2/types
context
|
Scope under which the request is made; determines fields present in response.
Default: One of: |
GET /wp/v2/types/<type>
Query this endpoint to retrieve a specific type record.
$ curl https://example.com/wp-json/wp/v2/types/<type>
type
|
An alphanumeric identifier for the post type. |
context
|
Scope under which the request is made; determines fields present in response.
Default: One of: |