Resource URL
| Type | URL and Format |
|---|---|
| POST | https://public-api.wordpress.com/rest/v1/sites/$site/posts/$post_ID |
Method Parameters
| Parameter | Type | Description |
|---|---|---|
| $site | (int|string) | The site ID, The site domain |
| $post_ID | (int) | The post ID |
Query Parameters
| Parameter | Type | Description |
|---|---|---|
| context | (string) |
|
| http_envelope | (bool) |
|
| pretty | (bool) |
|
| callback | (string) | An optional JSONP callback function. |
Request Parameters
| Parameter | Type | Description |
|---|---|---|
| date | (iso 8601 datetime) | The post's creation time. |
| title | (html) | The post title. |
| content | (html) | The post content. |
| excerpt | (html) | An optional post excerpt. |
| slug | (string) | The name (slug) for your post, used in URLs. |
| publicize | (array|bool) | True or false if the post be publicized to external services. An array of services if we only want to publicize to a select few. Defaults to true. |
| publicize_message | (string) | Custom message to be publicized to external services. |
| status | (string) |
|
| password | (string) | The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected. |
| parent | (int) | The post ID of the new post's parent. |
| categories | (string) | Comma separated list of categories (name or id) |
| tags | (string) | Comma separated list of tags (name or id) |
| format | (string) |
|
| comments_open | (bool) | Should the post be open to comments? |
| pings_open | (bool) | Should the post be open to comments? |
| metadata | (array) | Array of metadata objects containing the following properties: `key` (metadata key), `id` (meta ID), `previous_value` (if set, the action will only occur for the provided previous value), `value` (the new value to set the meta to), `operation` (the operation to perform: `update` or `add`; defaults to `update`). All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are avaiable for authenticated requests with access. Protected meta keys can be made available with the rest_api_allowed_public_metadata filter. |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| ID | (int) | The post ID. |
| author | (object) | The author of the post. |
| date | (iso 8601 datetime) | The post's creation time. |
| modified | (iso 8601 datetime) | The post's creation time. |
| title | (html) | context dependent. |
| URL | (url) | The full permalink URL to the post. |
| short_URL | (url) | The wp.me short URL. |
| content | (html) | context dependent. |
| excerpt | (html) | context dependent. |
| slug | (string) | The name (slug) for your post, used in URLs. |
| status | (string) |
|
| password | (string) | The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected. |
| parent | (object|false) | A reference to the post's parent, if it has one. |
| type | (string) | The post's post_type. Post types besides post and page need to be whitelisted using the rest_api_allowed_post_types filter. |
| comments_open | (bool) | Is the post open for comments? |
| pings_open | (bool) | Is the post open for pingbacks, trackbacks? |
| comment_count | (int) | The number of comments for this post. |
| like_count | (int) | The number of likes for this post. |
| i_like | (bool) | Does the current user like this post? |
| is_reblogged | (bool) | Did the current user reblog this post? |
| is_following | (bool) | Is the current user following this blog? |
| featured_image | (url) | The URL to the featured image for this post if it has one. |
| format | (string) |
|
| geo | (object|false) | |
| publicize_URLs | (array) | Array of Twitter and Facebook URLs published by this post. |
| tags | (object) | Hash of tags (keyed by tag name) applied to the post. |
| categories | (object) | Hash of categories (keyed by category name) applied to the post. |
| attachments | (object) | Hash of post attachments (keyed by attachment ID). |
| metadata | (array) | Array of post metadata keys and values. All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are avaiable for authenticated requests with access. Protected meta keys can be made available with the rest_api_allowed_public_metadata filter. |
| meta | (object) | API result meta data |
Example
cURL
curl \ -H 'authorization: Bearer YOUR_API_TOKEN' \ --data-urlencode 'title=Hello World (Again)' \ --data-urlencode 'content=Hello. I am an edited post. I was edited by the API' \ --data-urlencode 'tags=tests' \ --data-urlencode 'categories=API' \ 'https://public-api.wordpress.com/rest/v1/sites/30434183/posts/1222/'
PHP
<?php
$options = array (
'http' =>
array (
'ignore_errors' => true,
'method' => 'POST',
'header' =>
array (
0 => 'authorization: Bearer YOUR_API_TOKEN',
1 => 'Content-Type: application/x-www-form-urlencoded',
),
'content' => http_build_query(
array (
'title' => 'Hello World (Again)',
'content' => 'Hello. I am an edited post. I was edited by the API',
'tags' => 'tests',
'categories' => 'API',
)
),
),
);
$context = stream_context_create( $options );
$response = file_get_contents(
'https://public-api.wordpress.com/rest/v1/sites/30434183/posts/1222/',
false,
$context
);
$response = json_decode( $response );
?>
Response Body
{
"ID": 1222,
"author": {
"ID": 422,
"email": false,
"name": "Justin Shreve",
"URL": "http:\/\/justin.wordpress.com",
"avatar_URL": "http:\/\/1.gravatar.com\/avatar\/9ea5b460afb2859968095ad3afe4804b?s=96&d=identicon&r=G",
"profile_URL": "http:\/\/en.gravatar.com\/justin"
},
"date": "2012-04-11T15:53:52+00:00",
"modified": "2012-04-11T19:44:35+00:00",
"title": "Hello World (Again)",
"URL": "http:\/\/opossumapi.wordpress.com\/2012\/04\/11\/hello-world-2\/",
"short_URL": "http:\/\/wp.me\/p23HjV-jI",
"content": "<p>Hello. I am an edited post. I was edited by the API<\/p>\n",
"excerpt": "<p>Hello. I am an edited post. I was edited by the API<\/p>\n",
"status": "publish",
"password": "",
"parent": false,
"type": "post",
"comments_open": true,
"pings_open": true,
"comment_count": 5,
"like_count": 0,
"i_like": false,
"is_reblogged": false,
"is_following": false,
"featured_image": "",
"format": "standard",
"geo": false,
"publicize_URLs": [
],
"tags": {
"tests": {
"name": "tests",
"slug": "tests",
"description": "",
"post_count": 2,
"meta": {
"links": {
"self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/30434183\/tags\/tests",
"help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/30434183\/tags\/tests\/help",
"site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/30434183"
}
}
}
},
"categories": {
"API": {
"name": "API",
"slug": "api",
"description": "",
"post_count": 2,
"parent": 0,
"meta": {
"links": {
"self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/30434183\/categories\/api",
"help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/30434183\/categories\/api\/help",
"site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/30434183"
}
}
}
},
"metadata {
{
"id" : 123,
"key" : "test_meta_key",
"value" : "test_value",
}
},
"meta": {
"links": {
"self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/30434183\/posts\/1222",
"help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/30434183\/posts\/1222\/help",
"site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/30434183",
"replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/30434183\/posts\/1222\/replies\/",
"likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/30434183\/posts\/1222\/likes\/"
}
}
}