GET /sites/$site/posts/

Get a list of matching posts.

Resource Information

Method GET
Requires authentication? No

Method Parameters

Parameter Type Description
$site (int|string) Site ID or domain

Query Parameters

Parameter Type Description
context (string)
(default) Formats the output as HTML for display. Shortcodes are parsed, paragraph tags are added, etc..
Formats the output for editing. Shortcodes are left unparsed, significant whitespace is kept, etc..
http_envelope (bool)
Some environments (like in-browser JavaScript or Flash) block or divert responses with a non-200 HTTP status code. Setting this parameter will force the HTTP status code to always be 200. The JSON response is wrapped in an "envelope" containing the "real" HTTP status code and headers.
pretty (bool)
Output pretty JSON
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)
(default) Return posts in descending order. For dates, that means newest to oldest.
Return posts in ascending order. For dates, that means oldest to newest.
order_by (string)
(default) Order by the created time of each post.
Order by the modified time of each post.
Order lexicographically by the posts' titles.
Order by the number of comments for each post.
Order by post ID.
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.
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)
(default) Sticky posts are not excluded from the list.
Sticky posts are excluded from the list.
Only include sticky posts
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

These are the possible errors returned by this endpoint.

HTTP Code Error Identifier Error Message
400 invalid_field Invalid API FIELD
403 unauthorized User cannot access this private blog.
403 unauthorized User cannot access this restricted blog
400 invalid_context Invalid API CONTEXT
404 invalid_meta_key Invalid meta key
404 unknown_post_type Unknown post type
400 invalid_number The NUMBER parameter must be less than or equal to 100.


curl ''
$options  = array (
  'http' => 
  array (
    'ignore_errors' => true,

$context  = stream_context_create( $options );
$response = file_get_contents(
$response = json_decode( $response );