---
name: wpcontent
description: "Search, read, create, update, and delete WordPress posts and pages."
---

# WordPress Content

Search, read, create, update, and delete WordPress posts and pages.

## Functions

### `window._web_skills.wpcontent.searchposts(input)`

**Purpose:** Search posts by query string with optional filters.

**Input:**

```json
{
    "type": "object",
    "properties": {
        "query": {
            "type": "string",
            "description": "Search query"
        },
        "postType": {
            "type": "string",
            "description": "Post type slug (default: post)",
            "default": "post"
        },
        "status": {
            "type": "string",
            "description": "Post status (default: publish)",
            "default": "publish"
        },
        "limit": {
            "type": "integer",
            "description": "Max results (default: 10)",
            "default": 10
        }
    },
    "required": [
        "query"
    ]
}
```

**Output:**

```json
{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "id": {
                "type": "integer"
            },
            "title": {
                "type": "string"
            },
            "excerpt": {
                "type": "string"
            },
            "url": {
                "type": "string"
            },
            "date": {
                "type": "string"
            },
            "status": {
                "type": "string"
            }
        }
    }
}
```

### `window._web_skills.wpcontent.getpost(input)`

**Purpose:** Get a single post by ID.

**Input:**

```json
{
    "type": "object",
    "properties": {
        "id": {
            "type": "integer",
            "description": "Post ID"
        }
    },
    "required": [
        "id"
    ]
}
```

**Output:**

```json
{
    "type": "object",
    "properties": {
        "id": {
            "type": "integer"
        },
        "title": {
            "type": "string"
        },
        "content": {
            "type": "string"
        },
        "excerpt": {
            "type": "string"
        },
        "url": {
            "type": "string"
        },
        "date": {
            "type": "string"
        },
        "status": {
            "type": "string"
        },
        "author": {
            "type": "string"
        }
    }
}
```

### `window._web_skills.wpcontent.createdraft(input)`

**Purpose:** Create a draft post (requires authentication).

**Input:**

```json
{
    "type": "object",
    "properties": {
        "title": {
            "type": "string",
            "description": "Post title"
        },
        "content": {
            "type": "string",
            "description": "Post content (HTML)"
        },
        "postType": {
            "type": "string",
            "description": "Post type (default: post)",
            "default": "post"
        }
    },
    "required": [
        "title",
        "content"
    ]
}
```

**Output:**

```json
{
    "type": "object",
    "properties": {
        "id": {
            "type": "integer"
        },
        "title": {
            "type": "string"
        },
        "url": {
            "type": "string"
        }
    }
}
```

### `window._web_skills.wpcontent.updatepost(input)`

**Purpose:** Update an existing post (title, content, or status). Requires authentication.

**Input:**

```json
{
    "type": "object",
    "properties": {
        "id": {
            "type": "integer",
            "description": "Post ID"
        },
        "title": {
            "type": "string",
            "description": "New title (optional)"
        },
        "content": {
            "type": "string",
            "description": "New content HTML (optional)"
        },
        "status": {
            "type": "string",
            "description": "New status: publish, draft, trash (optional)"
        }
    },
    "required": [
        "id"
    ]
}
```

**Output:**

```json
{
    "type": "object",
    "properties": {
        "id": {
            "type": "integer"
        },
        "title": {
            "type": "string"
        },
        "status": {
            "type": "string"
        },
        "url": {
            "type": "string"
        }
    }
}
```

### `window._web_skills.wpcontent.deletepost(input)`

**Purpose:** Move a post to trash, or permanently delete if already trashed. Requires authentication.

**Input:**

```json
{
    "type": "object",
    "properties": {
        "id": {
            "type": "integer",
            "description": "Post ID"
        },
        "force": {
            "type": "boolean",
            "description": "Skip trash and permanently delete (default: false)",
            "default": false
        }
    },
    "required": [
        "id"
    ]
}
```

**Output:**

```json
{
    "type": "object",
    "properties": {
        "id": {
            "type": "integer"
        },
        "deleted": {
            "type": "boolean"
        },
        "message": {
            "type": "string"
        }
    }
}
```

## Runtime

All functions are available on `window._web_skills.wpcontent` and return Promises.

Metadata is available at `window._web_skills.wpcontent._meta`.
