These routes allow you to retrieve taxonomies.
Possible routes (endpoints are described below):
/wp/v2/taxonomies // works with all taxonomies
/wp/v2/taxonomies/{taxonomy} // works with the specified taxonomy instead of {taxonomy}
Controller class: WP_REST_Taxonomies_Controller{}
Resource Schema
The schema shows all fields that exist for the object: the fields of the object that the request will return.
Parameter |
Context |
Description |
capabilities object |
edit |
All capabilities used by the taxonomy. Read-only. |
description string |
view, edit |
Description of the taxonomy. Read-only. |
hierarchical boolean |
view, edit |
Whether the taxonomy is hierarchical or not. Read-only. |
labels object |
edit |
Titles of the taxonomy (various names). Read-only. |
name string |
view, edit, embed |
Name of the taxonomy. Read-only. |
slug string |
view, edit, embed |
Alphanumeric identifier for the taxonomy. Read-only. |
show_cloud boolean |
edit |
Whether to show the cloud of terms. Read-only. |
types array |
view, edit |
Types associated with the taxonomy. Read-only. |
rest_base string |
view, edit, embed |
Base REST API path for the taxonomy. Read-only. |
Route Description
An OPTIONS request to the route will return a complete description of this route: endpoints, their parameters, schema.
$ curl -X OPTIONS -i http://demo.wp-api.org/wp-json/wp/v2/taxonomies
GitHub
{
"namespace": "wp/v2",
"methods": [
"GET"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"embed",
"edit"
],
"description": "Рамки в которых сделан запрос, определяют поля в ответе.",
"type": "string"
},
"type": {
"required": false,
"description": "Ограничить выборку таксономиями ассоциированными с определенным типом записи.",
"type": "string"
}
}
}
],
"schema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "taxonomy",
"type": "object",
"properties": {
"capabilities": {
"description": "Все возможности используемые таксономией.",
"type": "object",
"context": [
"edit"
],
"readonly": true
},
"description": {
"description": "Человекочитаемое описание таксономии.",
"type": "string",
"context": [
"view",
"edit"
],
"readonly": true
},
"hierarchical": {
"description": "Может ли таксономия быть родительской.",
"type": "boolean",
"context": [
"view",
"edit"
],
"readonly": true
},
"labels": {
"description": "Человекочитаемые метки таксономии для различных контекстов.",
"type": "object",
"context": [
"edit"
],
"readonly": true
},
"name": {
"description": "Название таксономии.",
"type": "string",
"context": [
"view",
"edit",
"embed"
],
"readonly": true
},
"slug": {
"description": "Буквенно-цифровой идентификатор таксономии.",
"type": "string",
"context": [
"view",
"edit",
"embed"
],
"readonly": true
},
"show_cloud": {
"description": "Должно ли быть показано облако элементов.",
"type": "boolean",
"context": [
"edit"
],
"readonly": true
},
"types": {
"description": "Типы ассоциированные с таксономией.",
"type": "array",
"items": {
"type": "string"
},
"context": [
"view",
"edit"
],
"readonly": true
},
"rest_base": {
"description": "базовый путь REST для таксономии.",
"type": "string",
"context": [
"view",
"edit",
"embed"
],
"readonly": true
}
}
},
"_links": {
"self": "http://wp-test.ru/wp-json/wp/v2/taxonomies"
}
}
$ curl -X OPTIONS -i http://demo.wp-api.org/wp-json/wp/v2/taxonomies/{taxonomy}
GitHub
{
"namespace": "wp/v2",
"methods": [
"GET"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"taxonomy": {
"required": false,
"description": "Буквенно-цифровой идентификатор таксономии.",
"type": "string"
},
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"embed",
"edit"
],
"description": "Рамки в которых сделан запрос, определяют поля в ответе.",
"type": "string"
}
}
}
],
"schema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "taxonomy",
"type": "object",
"properties": {
"capabilities": {
"description": "Все возможности используемые таксономией.",
"type": "object",
"context": [
"edit"
],
"readonly": true
},
"description": {
"description": "Человекочитаемое описание таксономии.",
"type": "string",
"context": [
"view",
"edit"
],
"readonly": true
},
"hierarchical": {
"description": "Может ли таксономия быть родительской.",
"type": "boolean",
"context": [
"view",
"edit"
],
"readonly": true
},
"labels": {
"description": "Человекочитаемые метки таксономии для различных контекстов.",
"type": "object",
"context": [
"edit"
],
"readonly": true
},
"name": {
"description": "Название таксономии.",
"type": "string",
"context": [
"view",
"edit",
"embed"
],
"readonly": true
},
"slug": {
"description": "Буквенно-цифровой идентификатор таксономии.",
"type": "string",
"context": [
"view",
"edit",
"embed"
],
"readonly": true
},
"show_cloud": {
"description": "Должно ли быть показано облако элементов.",
"type": "boolean",
"context": [
"edit"
],
"readonly": true
},
"types": {
"description": "Типы ассоциированные с таксономией.",
"type": "array",
"items": {
"type": "string"
},
"context": [
"view",
"edit"
],
"readonly": true
},
"rest_base": {
"description": "базовый путь REST для таксономии.",
"type": "string",
"context": [
"view",
"edit",
"embed"
],
"readonly": true
}
}
}
}
List of Taxonomies
The algorithm is similar to the function get_taxonomies().
Request Type
Access: public
GET /wp/v2/taxonomies
Request Parameters
- context
- The context in which the request is made; defines the fields present in the response. Can be view, embed, edit.
Default: view
- type
- Limit the results to taxonomies associated with a specific post type.
Example Request
$ curl http://demo.wp-api.org/wp-json/wp/v2/taxonomies
The result of the taxonomy request on a freshly installed WordPress:
{
"category": {
"name": "Categories",
"slug": "category",
"description": "",
"types": [
"post"
],
"hierarchical": true,
"rest_base": "categories",
"_links": {
"collection": [
{
"href": "http://wp-test.ru/wp-json/wp/v2/taxonomies"
}
],
"wp:items": [
{
"href": "http://wp-test.ru/wp-json/wp/v2/categories"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
},
"post_tag": {
"name": "Tags",
"slug": "post_tag",
"description": "",
"types": [
"post"
],
"hierarchical": false,
"rest_base": "tags",
"_links": {
"collection": [
{
"href": "http://wp-test.ru/wp-json/wp/v2/taxonomies"
}
],
"wp:items": [
{
"href": "http://wp-test.ru/wp-json/wp/v2/tags"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
}
}
Retrieving a Taxonomy
The algorithm is similar to the function get_taxonomy(), but the set of returned data is limited by the schema.
Request Type
Access: public
GET /wp/v2/taxonomies/{taxonomy}
Request Parameters
- context
- The context in which the request is made; defines the fields present in the response. Can be view, embed, edit.
Default: view
Example Request
$ curl http://demo.wp-api.org/wp-json/wp/v2/taxonomies/category
{
"name": "Categories",
"slug": "category",
"description": "",
"types": [
"post"
],
"hierarchical": true,
"rest_base": "categories",
"_links": {
"collection": [
{
"href": "http://example.com/wp-json/wp/v2/taxonomies"
}
],
"wp:items": [
{
"href": "http://example.com/wp-json/wp/v2/categories"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
}