GET /sites/$site/post-types

Get a list of post types available for a site.

Resource Information

   
Method GET
URL https://public-api.wordpress.com/rest/v1.1/sites/$site/post-types
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.
api_queryable (bool) If true, only queryable post types are returned

Response Parameters

Parameter Type Description
found (int) The number of post types found
post_types (array) A list of available post types

Resource Errors

These are the possible errors returned by this endpoint.

HTTP Code Error Identifier Error Message
403 unauthorized User cannot access this private blog.
403 unauthorized User cannot access this restricted blog

Example

curl 'https://public-api.wordpress.com/rest/v1.1/sites/33534099/post-types'
<?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/33534099/post-types',
	false,
	$context
);
$response = json_decode( $response );
?>

Response

{
    "found": 3,
    "post_types": [
        {
            "name": "post",
            "label": "Posts",
            "labels": {
                "name": "Posts",
                "singular_name": "Post",
                "add_new": "Add New",
                "add_new_item": "Add New Post",
                "edit_item": "Edit Post",
                "new_item": "New Post",
                "view_item": "View Post",
                "search_items": "Search Posts",
                "not_found": "No posts found.",
                "not_found_in_trash": "No posts found in Trash.",
                "parent_item_colon": null,
                "all_items": "All Posts",
                "archives": "Post Archives",
                "insert_into_item": "Insert into post",
                "uploaded_to_this_item": "Uploaded to this post",
                "featured_image": "Featured Image",
                "set_featured_image": "Set featured image",
                "remove_featured_image": "Remove featured image",
                "use_featured_image": "Use as featured image",
                "filter_items_list": "Filter posts list",
                "items_list_navigation": "Posts list navigation",
                "items_list": "Posts list",
                "menu_name": "Posts",
                "name_admin_bar": "Post"
            },
            "description": "",
            "map_meta_cap": true,
            "capabilities": {
                "edit_post": "edit_post",
                "read_post": "read_post",
                "delete_post": "delete_post",
                "edit_posts": "edit_posts",
                "edit_others_posts": "edit_others_posts",
                "publish_posts": "publish_posts",
                "read_private_posts": "read_private_posts",
                "read": "read",
                "delete_posts": "delete_posts",
                "delete_private_posts": "delete_private_posts",
                "delete_published_posts": "delete_published_posts",
                "delete_others_posts": "delete_others_posts",
                "edit_private_posts": "edit_private_posts",
                "edit_published_posts": "edit_published_posts",
                "create_posts": "edit_posts"
            },
            "hierarchical": false,
            "api_queryable": true,
            "supports": {
                "writing-helper": true,
                "title": true,
                "editor": true,
                "author": true,
                "thumbnail": true,
                "excerpt": true,
                "trackbacks": true,
                "custom-fields": true,
                "comments": true,
                "revisions": true,
                "post-formats": true,
                "amp": true,
                "geo-location": true,
                "wpcom-markdown": true,
                "tags": true
            }
        },
        {
            "name": "page",
            "label": "Pages",
            "labels": {
                "name": "Pages",
                "singular_name": "Page",
                "add_new": "Add New",
                "add_new_item": "Add New Page",
                "edit_item": "Edit Page",
                "new_item": "New Page",
                "view_item": "View Page",
                "search_items": "Search Pages",
                "not_found": "No pages found.",
                "not_found_in_trash": "No pages found in Trash.",
                "parent_item_colon": "Parent Page:",
                "all_items": "All Pages",
                "archives": "Page Archives",
                "insert_into_item": "Insert into page",
                "uploaded_to_this_item": "Uploaded to this page",
                "featured_image": "Featured Image",
                "set_featured_image": "Set featured image",
                "remove_featured_image": "Remove featured image",
                "use_featured_image": "Use as featured image",
                "filter_items_list": "Filter pages list",
                "items_list_navigation": "Pages list navigation",
                "items_list": "Pages list",
                "menu_name": "Pages",
                "name_admin_bar": "Page"
            },
            "description": "",
            "map_meta_cap": true,
            "capabilities": {
                "edit_post": "edit_page",
                "read_post": "read_page",
                "delete_post": "delete_page",
                "edit_posts": "edit_pages",
                "edit_others_posts": "edit_others_pages",
                "publish_posts": "publish_pages",
                "read_private_posts": "read_private_pages",
                "read": "read",
                "delete_posts": "delete_pages",
                "delete_private_posts": "delete_private_pages",
                "delete_published_posts": "delete_published_pages",
                "delete_others_posts": "delete_others_pages",
                "edit_private_posts": "edit_private_pages",
                "edit_published_posts": "edit_published_pages",
                "create_posts": "edit_pages"
            },
            "hierarchical": true,
            "api_queryable": true,
            "supports": {
                "writing-helper": true,
                "title": true,
                "editor": true,
                "author": true,
                "thumbnail": true,
                "page-attributes": true,
                "custom-fields": true,
                "comments": true,
                "revisions": true,
                "geo-location": true,
                "excerpt": true,
                "wpcom-markdown": true
            }
        },
        {
            "name": "attachment",
            "label": "Media",
            "labels": {
                "name": "Media",
                "singular_name": "Media",
                "add_new": "Add New",
                "add_new_item": "Add New Post",
                "edit_item": "Edit Media",
                "new_item": "New Post",
                "view_item": "View Attachment Page",
                "search_items": "Search Posts",
                "not_found": "No posts found.",
                "not_found_in_trash": "No posts found in Trash.",
                "parent_item_colon": null,
                "all_items": "Media",
                "archives": "Media",
                "insert_into_item": "Insert into post",
                "uploaded_to_this_item": "Uploaded to this post",
                "featured_image": "Featured Image",
                "set_featured_image": "Set featured image",
                "remove_featured_image": "Remove featured image",
                "use_featured_image": "Use as featured image",
                "filter_items_list": "Filter posts list",
                "items_list_navigation": "Posts list navigation",
                "items_list": "Posts list",
                "menu_name": "Media",
                "name_admin_bar": "Media"
            },
            "description": "",
            "map_meta_cap": true,
            "capabilities": {
                "edit_post": "edit_post",
                "read_post": "read_post",
                "delete_post": "delete_post",
                "edit_posts": "edit_posts",
                "edit_others_posts": "edit_others_posts",
                "publish_posts": "publish_posts",
                "read_private_posts": "read_private_posts",
                "read": "read",
                "delete_posts": "delete_posts",
                "delete_private_posts": "delete_private_posts",
                "delete_published_posts": "delete_published_posts",
                "delete_others_posts": "delete_others_posts",
                "edit_private_posts": "edit_private_posts",
                "edit_published_posts": "edit_published_posts",
                "create_posts": "upload_files"
            },
            "hierarchical": false,
            "api_queryable": false,
            "supports": {
                "title": true,
                "author": true,
                "comments": true
            }
        }
    ]
}