wordpress REST API 手册 —- 分类(Categories)
TOPICS
Schema Schema
The schema defines all the fields that exist for a category object.
| id
integer |
Unique identifier for the term.
Read only Context: view, embed, edit |
| count
integer |
Number of published posts for the term.
Read only Context: view, edit |
| description
string |
HTML description of the term.
Context: view, edit |
| link
string, |
URL of the term.
Read only Context: view, embed, edit |
| name
string |
HTML title for the term.
Context: view, embed, edit |
| slug
string |
An alphanumeric identifier for the term unique to its type.
Context: view, embed, edit |
| taxonomy
string |
Type attribution for the term.
Read only Context: view, embed, edit One of: category, post_tag, nav_menu, link_category, post_format |
| parent
integer |
The parent term ID.
Context: view, edit |
| meta
object |
Meta fields.
Context: view, edit |
Example Request Example Request
$ curl -X OPTIONS -i https://example.com/wp-json/wp/v2/categories
List Categories List Categories
Arguments Arguments
| context | Scope under which the request is made; determines fields present in response.
Default: view One of: view, embed, edit |
| page | Current page of the collection.
Default: 1 |
| per_page | Maximum number of items to be returned in result set.
Default: 10 |
| search | Limit results to those matching a string. |
| exclude | Ensure result set excludes specific IDs. |
| include | Limit result set to specific IDs. |
| order | Order sort attribute ascending or descending.
Default: asc One of: asc, desc |
| orderby | Sort collection by term attribute.
Default: name One of: id, include, name, slug, include_slugs, term_group, description, count |
| hide_empty | Whether to hide terms not assigned to any posts. |
| parent | Limit result set to terms assigned to a specific parent. |
| post | Limit result set to terms assigned to a specific post. |
| slug | Limit result set to terms with one or more specific slugs. |
Definition Definition
GET /wp/v2/categories
Example Request Example Request
$ curl https://example.com/wp-json/wp/v2/categories
Create a Category Create a Category
Arguments Arguments
| description | HTML description of the term. |
| name | HTML title for the term.
Required: 1 |
| slug | An alphanumeric identifier for the term unique to its type. |
| parent | The parent term ID. |
| meta | Meta fields. |
Definition Definition
POST /wp/v2/categories
Retrieve a Category Retrieve a Category
Arguments Arguments
| id | Unique identifier for the term. |
| context | Scope under which the request is made; determines fields present in response.
Default: view One of: view, embed, edit |
Definition Definition
GET /wp/v2/categories/<id>
Example Request Example Request
$ curl https://example.com/wp-json/wp/v2/categories/<id>
Update a Category Update a Category
Arguments Arguments
| id | Unique identifier for the term. |
| description | HTML description of the term. |
| name | HTML title for the term. |
| slug | An alphanumeric identifier for the term unique to its type. |
| parent | The parent term ID. |
| meta | Meta fields. |
Definition Definition
POST /wp/v2/categories/<id>
Example Request Example Request
Delete a Category Delete a Category
Arguments Arguments
| id | Unique identifier for the term. |
| force | Required to be true, as terms do not support trashing. |
Definition Definition
DELETE /wp/v2/categories/<id>
Example Request Example Request
$ curl -X DELETE https://example.com/wp-json/wp/v2/categories/<id>