Blocks
These routes allow you to retrieve/create/update/delete blocks or a single block (record). Added in WP 5.0.
Possible routes (endpoints are described below):
/wp/v2/blocks // works with all blocks (post types) /wp/v2/blocks/{ID} // works with the specified block instead of {ID}
Controller class: WP_REST_Blocks_Controller{}
Resource Schema
Параметр | Контекст | Описание |
---|---|---|
date string/null |
view, edit, embed | The date the post was published, in the site's timezone. |
date_gmt string/null |
view, edit | The date the post was published, as GMT. |
guid object readonly |
view, edit | The globally unique identifier for the post. |
id integer readonly |
view, edit, embed | Unique identifier for the post. |
link string readonly |
view, edit, embed | URL to the post. |
modified string readonly |
view, edit | The date the post was last modified, in the site's timezone. |
modified_gmt string readonly |
view, edit | The date the post was last modified, as GMT. |
slug string |
view, edit, embed | An alphanumeric identifier for the post unique to its type. |
status string |
view, edit | A named status for the post. One of: publish, future, draft, pending, private |
type string readonly |
view, edit, embed | Type of post. |
password string |
edit | A password to protect access to the content and excerpt. |
template string |
view, edit | The theme file to use to display the post. |
title ** |
any | |
content ** |
any |
"date": { "description": "The date the object was published, in the site's timezone.", "type": "string", "format": "date-time", "context": [ "view", "edit", "embed" ] }, "date_gmt": { "description": "The date the object was published, as GMT.", "type": "string", "format": "date-time", "context": [ "view", "edit" ] }, "guid": { "description": "The globally unique identifier for the object.", "type": "object", "context": [ "view", "edit" ], "readonly": true, "properties": { "raw": { "description": "GUID for the object, as it exists in the database.", "type": "string", "context": [ "edit" ], "readonly": true }, "rendered": { "description": "GUID for the object, transformed for display.", "type": "string", "context": [ "view", "edit" ], "readonly": true } } }, "id": { "description": "Unique identifier for the object.", "type": "integer", "context": [ "view", "edit", "embed" ], "readonly": true }, "link": { "description": "URL to the object.", "type": "string", "format": "uri", "context": [ "view", "edit", "embed" ], "readonly": true }, "modified": { "description": "The date the object was last modified, in the site's timezone.", "type": "string", "format": "date-time", "context": [ "view", "edit" ], "readonly": true }, "modified_gmt": { "description": "The date the object was last modified, as GMT.", "type": "string", "format": "date-time", "context": [ "view", "edit" ], "readonly": true }, "slug": { "description": "An alphanumeric identifier for the object unique to its type.", "type": "string", "context": [ "view", "edit", "embed" ] }, "status": { "description": "A named status for the object.", "type": "string", "enum": [ "publish", "future", "draft", "pending", "private" ], "context": [ "view", "edit" ] }, "type": { "description": "Type of Post for the object.", "type": "string", "context": [ "view", "edit", "embed" ], "readonly": true }, "password": { "description": "A password to protect access to the content and excerpt.", "type": "string", "context": [ "edit" ] }, "title": { "description": "The title for the object.", "type": "object", "context": [ "view", "edit", "embed" ], "properties": { "raw": { "description": "Title for the object, as it exists in the database.", "type": "string", "context": [ "view", "edit" ] } } }, "content": { "description": "The content for the object.", "type": "object", "context": [ "view", "edit" ], "properties": { "raw": { "description": "Content for the object, as it exists in the database.", "type": "string", "context": [ "view", "edit" ] }, "block_version": { "description": "Version of the content block format used by the object.", "type": "integer", "context": [ "edit" ], "readonly": true }, "protected": { "description": "Whether the content is protected with a password.", "type": "boolean", "context": [ "view", "edit", "embed" ], "readonly": true } } }, "template": { "description": "The theme file to use to display the object.", "type": "string", "context": [ "view", "edit" ] }
wp/v2/blocks
An OPTIONS request to the route will return a full description of this route: endpoints, their parameters, schema.
$ curl -X OPTIONS -i http://demo.wp-api.org/wp-json/wp/v2/blocksGitHub
{ "namespace": "wp/v2", "methods": [ "GET", "POST" ], "endpoints": [ { "methods": [ "GET" ], "args": { "context": { "required": false, "default": "view", "enum": [ "view", "embed", "edit" ], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }, "page": { "required": false, "default": 1, "description": "Current page of the collection.", "type": "integer" }, "per_page": { "required": false, "default": 10, "description": "Maximum number of items to be returned in result set.", "type": "integer" }, "search": { "required": false, "description": "Limit results to those matching a string.", "type": "string" }, "after": { "required": false, "description": "Limit response to posts published after a given ISO8601 compliant date.", "type": "string" }, "before": { "required": false, "description": "Limit response to posts published before a given ISO8601 compliant date.", "type": "string" }, "exclude": { "required": false, "default": [], "description": "Ensure result set excludes specific IDs.", "type": "array", "items": { "type": "integer" } }, "include": { "required": false, "default": [], "description": "Limit result set to specific IDs.", "type": "array", "items": { "type": "integer" } }, "offset": { "required": false, "description": "Offset the result set by a specific number of items.", "type": "integer" }, "order": { "required": false, "default": "desc", "enum": [ "asc", "desc" ], "description": "Order sort attribute ascending or descending.", "type": "string" }, "orderby": { "required": false, "default": "date", "enum": [ "author", "date", "id", "include", "modified", "parent", "relevance", "slug", "include_slugs", "title" ], "description": "Sort collection by object attribute.", "type": "string" }, "slug": { "required": false, "description": "Limit result set to posts with one or more specific slugs.", "type": "array", "items": { "type": "string" } }, "status": { "required": false, "default": "publish", "description": "Limit result set to posts assigned one or more statuses.", "type": "array", "items": { "enum": [ "publish", "future", "draft", "pending", "private", "trash", "auto-draft", "inherit", "request-pending", "request-confirmed", "request-failed", "request-completed", "any" ], "type": "string" } } } }, { "methods": [ "POST" ], "args": { "date": { "required": false, "description": "The date the object was published, in the site's timezone.", "type": "string" }, "date_gmt": { "required": false, "description": "The date the object was published, as GMT.", "type": "string" }, "slug": { "required": false, "description": "An alphanumeric identifier for the object unique to its type.", "type": "string" }, "status": { "required": false, "enum": [ "publish", "future", "draft", "pending", "private" ], "description": "A named status for the object.", "type": "string" }, "password": { "required": false, "description": "A password to protect access to the content and excerpt.", "type": "string" }, "title": { "required": false, "description": "The title for the object.", "type": "object" }, "content": { "required": false, "description": "The content for the object.", "type": "object" }, "template": { "required": false, "description": "The theme file to use to display the object.", "type": "string" } } } ], "schema": { "$schema": "http://json-schema.org/draft-04/schema#", "title": "wp_block", "type": "object", "properties": { "date": { "description": "The date the object was published, in the site's timezone.", "type": "string", "format": "date-time", "context": [ "view", "edit", "embed" ] }, "date_gmt": { "description": "The date the object was published, as GMT.", "type": "string", "format": "date-time", "context": [ "view", "edit" ] }, "guid": { "description": "The globally unique identifier for the object.", "type": "object", "context": [ "view", "edit" ], "readonly": true, "properties": { "raw": { "description": "GUID for the object, as it exists in the database.", "type": "string", "context": [ "edit" ], "readonly": true }, "rendered": { "description": "GUID for the object, transformed for display.", "type": "string", "context": [ "view", "edit" ], "readonly": true } } }, "id": { "description": "Unique identifier for the object.", "type": "integer", "context": [ "view", "edit", "embed" ], "readonly": true }, "link": { "description": "URL to the object.", "type": "string", "format": "uri", "context": [ "view", "edit", "embed" ], "readonly": true }, "modified": { "description": "The date the object was last modified, in the site's timezone.", "type": "string", "format": "date-time", "context": [ "view", "edit" ], "readonly": true }, "modified_gmt": { "description": "The date the object was last modified, as GMT.", "type": "string", "format": "date-time", "context": [ "view", "edit" ], "readonly": true }, "slug": { "description": "An alphanumeric identifier for the object unique to its type.", "type": "string", "context": [ "view", "edit", "embed" ] }, "status": { "description": "A named status for the object.", "type": "string", "enum": [ "publish", "future", "draft", "pending", "private" ], "context": [ "view", "edit" ] }, "type": { "description": "Type of Post for the object.", "type": "string", "context": [ "view", "edit", "embed" ], "readonly": true }, "password": { "description": "A password to protect access to the content and excerpt.", "type": "string", "context": [ "edit" ] }, "title": { "description": "The title for the object.", "type": "object", "context": [ "view", "edit", "embed" ], "properties": { "raw": { "description": "Title for the object, as it exists in the database.", "type": "string", "context": [ "view", "edit" ] } } }, "content": { "description": "The content for the object.", "type": "object", "context": [ "view", "edit" ], "properties": { "raw": { "description": "Content for the object, as it exists in the database.", "type": "string", "context": [ "view", "edit" ] }, "block_version": { "description": "Version of the content block format used by the object.", "type": "integer", "context": [ "edit" ], "readonly": true }, "protected": { "description": "Whether the content is protected with a password.", "type": "boolean", "context": [ "view", "edit", "embed" ], "readonly": true } } }, "template": { "description": "The theme file to use to display the object.", "type": "string", "context": [ "view", "edit" ] } }, "links": [ { "rel": "https://api.w.org/action-publish", "title": "The current user can publish this post.", "href": "https://demo.wp-api.org/wp-json/wp/v2/blocks/{id}", "targetSchema": { "type": "object", "properties": { "status": { "type": "string", "enum": [ "publish", "future" ] } } } }, { "rel": "https://api.w.org/action-unfiltered-html", "title": "The current user can post unfiltered HTML markup and JavaScript.", "href": "https://demo.wp-api.org/wp-json/wp/v2/blocks/{id}", "targetSchema": { "type": "object", "properties": { "content": { "raw": { "type": "string" } } } } } ] }, "_links": { "self": "https://demo.wp-api.org/wp-json/wp/v2/blocks" } }
List of Posts
See description of the posts endpoint.
Creating a Posts
See description of the posts endpoint.
wp/v2/posts/{id}
An OPTIONS request to the route will return a full description of this route: endpoints, their parameters, schema.
$ curl -X OPTIONS -i http://demo.wp-api.org/wp-json/wp/v2/blocks/1GitHub
{ "namespace": "wp/v2", "methods": [ "GET", "POST", "PUT", "PATCH", "DELETE" ], "endpoints": [ { "methods": [ "GET" ], "args": { "id": { "required": false, "description": "Unique identifier for the object.", "type": "integer" }, "context": { "required": false, "default": "view", "enum": [ "view", "embed", "edit" ], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }, "password": { "required": false, "description": "The password for the post if it is password protected.", "type": "string" } } }, { "methods": [ "POST", "PUT", "PATCH" ], "args": { "id": { "required": false, "description": "Unique identifier for the object.", "type": "integer" }, "date": { "required": false, "description": "The date the object was published, in the site's timezone.", "type": "string" }, "date_gmt": { "required": false, "description": "The date the object was published, as GMT.", "type": "string" }, "slug": { "required": false, "description": "An alphanumeric identifier for the object unique to its type.", "type": "string" }, "status": { "required": false, "enum": [ "publish", "future", "draft", "pending", "private" ], "description": "A named status for the object.", "type": "string" }, "password": { "required": false, "description": "A password to protect access to the content and excerpt.", "type": "string" }, "title": { "required": false, "description": "The title for the object.", "type": "object" }, "content": { "required": false, "description": "The content for the object.", "type": "object" }, "template": { "required": false, "description": "The theme file to use to display the object.", "type": "string" } } }, { "methods": [ "DELETE" ], "args": { "id": { "required": false, "description": "Unique identifier for the object.", "type": "integer" }, "force": { "required": false, "default": false, "description": "Whether to bypass trash and force deletion.", "type": "boolean" } } } ], "schema": { "$schema": "http://json-schema.org/draft-04/schema#", "title": "wp_block", "type": "object", "properties": { "date": { "description": "The date the object was published, in the site's timezone.", "type": "string", "format": "date-time", "context": [ "view", "edit", "embed" ] }, "date_gmt": { "description": "The date the object was published, as GMT.", "type": "string", "format": "date-time", "context": [ "view", "edit" ] }, "guid": { "description": "The globally unique identifier for the object.", "type": "object", "context": [ "view", "edit" ], "readonly": true, "properties": { "raw": { "description": "GUID for the object, as it exists in the database.", "type": "string", "context": [ "edit" ], "readonly": true }, "rendered": { "description": "GUID for the object, transformed for display.", "type": "string", "context": [ "view", "edit" ], "readonly": true } } }, "id": { "description": "Unique identifier for the object.", "type": "integer", "context": [ "view", "edit", "embed" ], "readonly": true }, "link": { "description": "URL to the object.", "type": "string", "format": "uri", "context": [ "view", "edit", "embed" ], "readonly": true }, "modified": { "description": "The date the object was last modified, in the site's timezone.", "type": "string", "format": "date-time", "context": [ "view", "edit" ], "readonly": true }, "modified_gmt": { "description": "The date the object was last modified, as GMT.", "type": "string", "format": "date-time", "context": [ "view", "edit" ], "readonly": true }, "slug": { "description": "An alphanumeric identifier for the object unique to its type.", "type": "string", "context": [ "view", "edit", "embed" ] }, "status": { "description": "A named status for the object.", "type": "string", "enum": [ "publish", "future", "draft", "pending", "private" ], "context": [ "view", "edit" ] }, "type": { "description": "Type of Post for the object.", "type": "string", "context": [ "view", "edit", "embed" ], "readonly": true }, "password": { "description": "A password to protect access to the content and excerpt.", "type": "string", "context": [ "edit" ] }, "title": { "description": "The title for the object.", "type": "object", "context": [ "view", "edit", "embed" ], "properties": { "raw": { "description": "Title for the object, as it exists in the database.", "type": "string", "context": [ "view", "edit" ] } } }, "content": { "description": "The content for the object.", "type": "object", "context": [ "view", "edit" ], "properties": { "raw": { "description": "Content for the object, as it exists in the database.", "type": "string", "context": [ "view", "edit" ] }, "block_version": { "description": "Version of the content block format used by the object.", "type": "integer", "context": [ "edit" ], "readonly": true }, "protected": { "description": "Whether the content is protected with a password.", "type": "boolean", "context": [ "view", "edit", "embed" ], "readonly": true } } }, "template": { "description": "The theme file to use to display the object.", "type": "string", "context": [ "view", "edit" ] } }, "links": [ { "rel": "https://api.w.org/action-publish", "title": "The current user can publish this post.", "href": "https://demo.wp-api.org/wp-json/wp/v2/blocks/{id}", "targetSchema": { "type": "object", "properties": { "status": { "type": "string", "enum": [ "publish", "future" ] } } } }, { "rel": "https://api.w.org/action-unfiltered-html", "title": "The current user can post unfiltered HTML markup and JavaScript.", "href": "https://demo.wp-api.org/wp-json/wp/v2/blocks/{id}", "targetSchema": { "type": "object", "properties": { "content": { "raw": { "type": "string" } } } } } ] } }
Retrieving a Post
See description of the posts endpoint.
Updating a Post
See description of the posts endpoint.