`/wp/v2/categories`

Namespace: wp/v2
Route: /wp/v2/categories

Routes

  • Collection: /wp/v2/categories
  • Single: /wp/v2/categories/{id}

HTTP Methods

Collection methods: GET, POST

Single methods: GET, POST, PUT, PATCH, DELETE

Request Parameters

Collection GET

ParameterTypeRequiredDefaultDescription
contextstringfalseviewScope under which the request is made; determines fields present in response.
pageintegerfalse1Current page of the collection.
per_pageintegerfalse10Maximum number of items to be returned in result set.
searchstringfalseLimit results to those matching a string.
excludearrayfalse[]Ensure result set excludes specific IDs.
includearrayfalse[]Limit result set to specific IDs.
orderstringfalseascOrder sort attribute ascending or descending.
orderbystringfalsenameSort collection by term attribute.
hide_emptybooleanfalseFalseWhether to hide terms not assigned to any posts.
parentintegerfalseLimit result set to terms assigned to a specific parent.
postintegerfalseNoneLimit result set to terms assigned to a specific post.
slugarrayfalseLimit result set to terms with one or more specific slugs.

Collection POST

ParameterTypeRequiredDefaultDescription
descriptionstringfalseHTML description of the term.
namestringtrueHTML title for the term.
slugstringfalseAn alphanumeric identifier for the term unique to its type.
parentintegerfalseThe parent term ID.
metaobjectfalseMeta fields.

Single GET

ParameterTypeRequiredDefaultDescription
idintegerfalseUnique identifier for the term.
contextstringfalseviewScope under which the request is made; determines fields present in response.

Single POST, PUT, PATCH

ParameterTypeRequiredDefaultDescription
idintegerfalseUnique identifier for the term.
descriptionstringfalseHTML description of the term.
namestringfalseHTML title for the term.
slugstringfalseAn alphanumeric identifier for the term unique to its type.
parentintegerfalseThe parent term ID.
metaobjectfalseMeta fields.

Single DELETE

ParameterTypeRequiredDefaultDescription
idintegerfalseUnique identifier for the term.
forcebooleanfalseFalseRequired to be true, as terms do not support trashing.

Response Schema (Item)

FieldTypeDescription
idintegerUnique identifier for the term. (read-only)
countintegerNumber of published posts for the term. (read-only)
descriptionstringHTML description of the term.
linkstringURL of the term. (read-only)
namestringHTML title for the term.
slugstringAn alphanumeric identifier for the term unique to its type.
taxonomystringType attribution for the term. (read-only)
parentintegerThe parent term ID.
metaobjectMeta fields.

Authentication

  • Read: public.
  • Write: manage_categories/edit_terms for create/update/delete.

Example Requests

bash
curl -X GET "https://wordpress.org/news/wp-json/wp/v2/categories"
bash
curl -X POST "https://wordpress.org/news/wp-json/wp/v2/categories" 
  -H 'Authorization: Basic <app-password>' 
  -H 'Content-Type: application/json' 
  -d '{"title":"Example"}'
bash
curl -X GET "https://wordpress.org/news/wp-json/wp/v2/categories/1"

Example Response (trimmed)

json
{
  "id": 1,
  "_links": {
    "self": [{ "href": "/wp/v2/categories/1" }]
  }
}