Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

XML-RPC WordPress API/Posts

wp.getPost

Retrieve a post of any registered post type.

Added in WordPress 3.4.

Parameters

  • string username
  • string password
  • int post_id
  • array fields: Optional. List of field or meta-field names to include in response.

Return Values

  • struct: Note that the exact fields returned depends on the fields parameter.
    • string post_id
    • string post_title1
    • datetime post_date1
    • datetime post_date_gmt1
    • datetime post_modified1
    • datetime post_modified_gmt1
    • string post_status1
    • string post_type1
    • string post_format1
    • string post_name1
    • string post_author1 author id
    • string post_password1
    • string post_excerpt1
    • string post_content1
    • string post_parent1
    • string post_mime_type1
    • string link1
    • string guid1
    • int menu_order1
    • string comment_status1
    • string ping_status1
    • bool sticky1
    • struct post_thumbnail1: See wp.getMediaItem.
    • array terms
    • array custom_fields
      • struct
        • string id
        • string key
        • string value
    • struct enclosure
      • string url
      • int length
      • string type

1 post meta-field

Notes

  • In the older metaweblog API, the "Introduction" and the "Read More" content for a post were returned in separate fields "description" and "mt_text_more". In the WordPress API, the two values are combined in the single "post_content" field, separated by the <!--more--> tag.

Errors

  • 401
    • If user does not have permission to edit the post.
  • 404
    • If no post with that post_id exists.

Filters

xmlrpc_default_post_fields

The default set of fields to be returned can be controlled using the xmlrpc_default_post_fields filter. The default value for this filter is:

array( 'post', 'terms', 'custom_fields' )

xmlrpc_prepare_post

Immediately before returning the prepared post data, the value is passed through the xmlrpc_prepare_post filter. The filter has three parameters:

  1. The prepared post data about to be returned
  2. The original post data array, see get_post.
  3. The fields parameter value.

wp.getPosts

Retrieve list of posts of any registered post type.

Added in WordPress 3.4.

Parameters

  • int blog_id
  • string username
  • string password
  • struct filter: Optional.
    • string post_type
    • string post_status
    • int number
    • int offset
    • string orderby
    • string s
    • string order
  • array fields: Optional. See #wp.getPost.

Return Values

Notes

  • Response will only contain posts that the user has permission to edit. Therefore, there may be fewer than filter['number'] posts in the response.

Filters

Supports same filters as #wp.getPost.

wp.newPost

Create a new post of any registered post type.

Added in WordPress 3.4.

Parameters

  • int blog_id
  • string username
  • string password
  • struct content
    • string post_type
    • string post_status
    • string post_title
    • int post_author
    • string post_excerpt
    • string post_content
    • datetime post_date_gmt