GET /sites/$site/posts/

Get a list of matching posts.

Resource Information

   
Method GET
URL https://public-api.wordpress.com/rest/v1/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)
display:
(default) Formats the output as HTML for display. Shortcodes are parsed, paragraph tags are added, etc..
edit:
Formats the output for editing. Shortcodes are left unparsed, significant whitespace is kept, etc..
http_envelope (bool)
false:
(default)
true:
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)
false:
(default)
true:
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.
order (string)
DESC:
(default) Return posts in descending order. For dates, that means newest to oldest.
ASC:
Return posts in ascending order. For dates, that means oldest to newest.
order_by (string)
date:
(default) Order by the created time of each post.
modified:
Order by the modified time of each post.
title:
Order lexicographically by the posts' titles.
comment_count:
Order by the number of comments for each post.
ID:
Order by post ID.
after (iso 8601 datetime) Return posts dated on or after the specified datetime.
before (iso 8601 datetime) Return posts dated on or before the specified datetime.
tag (string) Specify the tag name or slug.
category (string) Specify the category name or 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)
publish:
(default) Return only published posts.
private:
Return only private posts.
draft:
Return only draft posts.
pending:
Return only posts pending editorial approval.
future:
Return only posts scheduled for future publishing.
trash:
Return only posts in the trash.
any:
Return all posts regardless of status.
sticky (bool)
false:
(default) Post is not marked as sticky.
true:
Stick the post to the front page.
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.

Resource Errors

This endpoint does not return any errors.

Example

curl 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/?number=5'
<?php
$options  = array (
  'http' => 
  array (
    'ignore_errors' => true,
  ),
);

$context  = stream_context_create( $options );
$response = file_get_contents(
	'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/?number=5',
	false,
	$context
);
$response = json_decode( $response );
?>