GET/sites/$site/posts/
Get a list of matching posts.
Resource Information
Method | GET |
---|---|
URL | https://public-api.wordpress.com/rest/v1.1/sites/$site/posts/ |
Requires authentication? | No |
Method Parameters
Parameter | Type | Description |
---|---|---|
$site | (int|string) | Site ID or domain |
Query Parameters
Parameter | Type | Description |
---|---|---|
context | (string) |
|
http_envelope | (bool) |
|
pretty | (bool) |
|
meta | (string) | Optional. Loads data from the endpoints found in the 'meta' part of the response. Comma-separated list. Example: meta=site,likes |
fields | (string) | Optional. Returns specified fields only. Comma-separated list. Example: fields=ID,title |
callback | (string) | An optional JSONP callback function. |
number | (int) | The number of posts to return. Limit: 100. Default: 20. |
offset | (int) | 0-indexed offset. |
page | (int) |
Return the Nth 1-indexed page of posts. Takes precedence over the offset parameter. |
page_handle | (string) |
A page handle, returned from a previous API call as a meta.next_page property. This is the most efficient way to fetch the next page of results. |
order | (string) |
|
order_by | (string) |
|
after | (iso 8601 datetime) | Return posts dated after the specified datetime. |
before | (iso 8601 datetime) | Return posts dated before the specified datetime. |
modified_after | (iso 8601 datetime) | Return posts modified after the specified datetime. |
modified_before | (iso 8601 datetime) | Return posts modified before the specified datetime. |
tag | (string) | Specify the tag name or slug. |
category | (string) | Specify the category name or slug. |
term | (object) | Specify comma-separated term slugs to search within, indexed by taxonomy slug. |
type | (string) |
Specify the post type. Defaults to 'post', use 'any' to query for both posts and pages. Post types besides post and page need to be whitelisted using the rest_api_allowed_post_types filter. |
parent_id | (int) | Returns only posts which are children of the specified post. Applies only to hierarchical post types. |
include | (array|int) | Includes the specified post ID(s) in the response |
exclude | (array|int) | Excludes the specified post ID(s) from the response |
exclude_tree | (int) | Excludes the specified post and all of its descendants from the response. Applies only to hierarchical post types. |
status | (string) | Comma-separated list of statuses for which to query, including any of: "publish", "private", "draft", "pending", "future", and "trash", or simply "any". Defaults to "publish" |
sticky | (string) |
|
author | (int) | Author's user ID |
search | (string) | Search query |
meta_key | (string) | Metadata key that the post should contain |
meta_value | (string) | Metadata value that the post should contain. Will only be applied if a `meta_key` is also given |
Response Parameters
Parameter | Type | Description |
---|---|---|
found | (int) | The total number of posts found that match the request (ignoring limits, offsets, and pagination). |
posts | (array) | An array of post objects. |
meta | (object) | Meta data |
Resource Errors
This endpoint does not return any errors.
Example
curl 'https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/posts/?number=2'
<?php $options = array ( 'http' => array ( 'ignore_errors' => true, ), ); $context = stream_context_create( $options ); $response = file_get_contents( 'https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/posts/?number=2', false, $context ); $response = json_decode( $response ); ?>