`/wp/v2/templates`

Namespace: wp/v2
Route: /wp/v2/templates

Routes

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

HTTP Methods

Collection methods: GET, POST

Single methods: GET, POST

Request Parameters

Collection GET

ParameterTypeRequiredDefaultDescription
contextstringfalseviewScope under which the request is made; determines fields present in response.
wp_idintegerfalseLimit to the specified post id.
areastringfalseLimit to the specified template part area.
post_typestringfalsePost type to get the templates for.

Collection POST

ParameterTypeRequiredDefaultDescription
slugstringtrueUnique slug identifying the template.
themestringfalseTheme identifier for the template.
typestringfalseType of template.
contentobject, stringfalseContent of template.
titleobject, stringfalseTitle of template.
descriptionstringfalseDescription of template.
statusstringfalsepublishStatus of template.
authorintegerfalseThe ID for the author of the template.

Single GET

ParameterTypeRequiredDefaultDescription
idstringfalseThe id of a template
contextstringfalseviewScope under which the request is made; determines fields present in response.

Single POST

ParameterTypeRequiredDefaultDescription
idstringfalseThe id of a template
slugstringfalseUnique slug identifying the template.
themestringfalseTheme identifier for the template.
typestringfalseType of template.
contentobject, stringfalseContent of template.
titleobject, stringfalseTitle of template.
descriptionstringfalseDescription of template.
statusstringfalseStatus of template.
authorintegerfalseThe ID for the author of the template.

Response Schema (Item)

FieldTypeDescription
idstringID of template. (read-only)
slugstringUnique slug identifying the template.
themestringTheme identifier for the template.
typestringType of template.
sourcestringSource of template (read-only)
originstringSource of a customized template (read-only)
contentobject, stringContent of template.
titleobject, stringTitle of template.
descriptionstringDescription of template.
statusstringStatus of template.
wp_idintegerPost ID. (read-only)
has_theme_fileboolTheme file exists. (read-only)
authorintegerThe ID for the author of the template.
modifiedstringThe date the template was last modified, in the site’s timezone. (read-only)
author_textstringHuman readable text for the author. (read-only)
original_sourcestringWhere the template originally comes from e.g. ‘theme’ (read-only)
is_customboolWhether a template is a custom template. (read-only)
pluginstringPlugin that registered the template. (read-only)

Authentication

  • Read/Write: edit_theme_options.

Example Requests

bash
curl -X GET "https://wordpress.org/news/wp-json/wp/v2/templates"
bash
curl -X POST "https://wordpress.org/news/wp-json/wp/v2/templates" 
  -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/templates/twentytwentyfour//index"

Example Response (trimmed)

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