Skip to content

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)
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.
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)
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 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)
include:
(default) Sticky posts are not excluded from the list.
exclude:
Sticky posts are excluded from the list.
require:
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

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 );
?>