Custom Post Type Toolswordpress_create_custom_post

wordpress_create_custom_post

Create a new custom post for a given post type.

wordpress_create_custom_post

Create a new custom post.

Parameters

15 parameters, 2 required.

NameTypeRequiredWhat it is
typestringyesPost type name (e.g. "post", "page", "product")
titlestringyesPost title
contentstringnoPost content
statusstringnoPost status (default: draft)
slugstringnoURL slug (post_name). Example: "my-post" produces /my-post/.
excerptstringnoOptional post excerpt.
datestringnoOptional publish date in YYYY-MM-DD HH:MM:SS (server local time) for backdating.
authoranynoAuthor (user id or user login). Requires edit_others_posts capability when different from the acting user.
categoriesarray of valuesnoShorthand for the built-in "category" taxonomy. Accepts term ids (number) or slugs/names (string).
tagsarray of valuesnoShorthand for the built-in "post_tag" taxonomy. Accepts term ids (number) or slugs/names (string).
taxonomiesobjectnoGeneric map of taxonomy slug to array of term ids/slugs for custom taxonomies (e.g. product_cat). Example: { "product_cat": [12, "featured"] }.
featured_medianumbernoAttachment ID to set as the featured image.
create_missing_termsbooleannoWhen true, auto-create taxonomy terms that do not exist by name. Default false (strict: unknown slug returns 400 and the post is rolled back).
post_parentnumbernoParent post ID. Pass 0 for no parent. Useful when creating sub-pages or nested custom post types.
metaobjectnoPost meta data (map of meta key to value).

Example call

The smallest valid call, with the required parameters only:

{
  "name": "wordpress_create_custom_post",
  "arguments": {
    "type": "value",
    "title": "Example title"
  }
}

Response

{
  "success": true,
  "type": "product",
  "id": 3002,
  "status": "draft"
}

What it changes

It writes to the site. Respira takes a snapshot before the write, and the change can be undone from that snapshot for 90 days. On a page or post the edit lands on a copy first. The live page changes only when a person approves the copy in wp-admin. Calling it twice does the work twice. On a connection set to read-only it is refused with respira_scope_denied.

When it fails

The failures seen most often on real sites in the last 30 days, most common first:

  • respira_post_type_not_found: That post type is not registered on the site. Call wordpress_list_post_types to see the ones that are.

How long it takes

A typical call takes about 4.0 seconds. 19 in 20 finish within 17.9 seconds. Measured on real sites over the last week, so it includes the site's own hosting.

Availability

Works on any WordPress site, whichever page builder it uses. Available since Respira 1.0.0.

Example Prompts

  • "Create a new product called 'Starter Plan'"
  • "Create a portfolio entry titled 'Case Study: Acme'"