productivity
WordPress Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the WordPress KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.wordpress.*.
Use lua_read_doc("integrations.wordpress") inside KosmoKrator to discover the same reference at runtime.
Call Lua from the Headless CLI
Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic
WordPress workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.wordpress.create_post({title = "example_title", content = "example_content", status = "example_status", excerpt = "example_excerpt", author = 1, categories = "example_categories", tags = "example_tags", featured_media = 1}))' --json kosmo integrations:lua --eval 'print(docs.read("wordpress"))' --json
kosmo integrations:lua --eval 'print(docs.read("wordpress.create_post"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local wordpress = app.integrations.wordpress
local result = wordpress.create_post({title = "example_title", content = "example_content", status = "example_status", excerpt = "example_excerpt", author = 1, categories = "example_categories", tags = "example_tags", featured_media = 1})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.wordpress, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.wordpress.default.* or app.integrations.wordpress.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need WordPress, use the narrower mcp:lua command.
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json Agent-Facing Lua Docs
This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.
WordPress — Lua API Reference
list_posts
List posts from the WordPress site.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
per_page | integer | no | Number of posts per page (default: 10, max: 100) |
page | integer | no | Page number (default: 1) |
search | string | no | Search term to filter by title or content |
status | string | no | Post status: publish, draft, pending, private, trash, any (default: publish) |
author | integer | no | Filter by author user ID |
categories | string | no | Comma-separated category IDs |
tags | string | no | Comma-separated tag IDs |
order | string | no | Sort order: asc or desc (default: desc) |
orderby | string | no | Sort field: date, title, author, id (default: date) |
Example
local result = app.integrations.wordpress.list_posts({
per_page = 5,
status = "publish",
orderby = "date",
order = "desc"
})
for _, post in ipairs(result) do
print(post.id .. ": " .. post.title.rendered)
end
get_post
Get a single post by ID.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | yes | The post ID |
Example
local post = app.integrations.wordpress.get_post({ id = 123 })
print(post.title.rendered)
print(post.content.rendered)
create_post
Create a new post. Defaults to draft status.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
title | string | yes | Post title |
content | string | no | Post content (HTML) |
status | string | no | draft, publish, pending, private (default: draft) |
excerpt | string | no | Post excerpt (HTML) |
author | integer | no | Author user ID |
categories | array | no | Array of category IDs |
tags | array | no | Array of tag IDs |
featured_media | integer | no | Featured image media ID |
slug | string | no | URL slug (auto-generated if omitted) |
Example
local post = app.integrations.wordpress.create_post({
title = "My New Post",
content = "<p>Hello world!</p>",
status = "draft",
categories = { 1, 5 }
})
print("Created post ID: " .. post.id)
update_post
Update an existing post.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | yes | Post ID to update |
title | string | no | New title |
content | string | no | New content (HTML) |
status | string | no | New status |
excerpt | string | no | New excerpt (HTML) |
author | integer | no | New author user ID |
categories | array | no | New category IDs (replaces existing) |
tags | array | no | New tag IDs (replaces existing) |
featured_media | integer | no | New featured image media ID |
slug | string | no | New URL slug |
Example
local post = app.integrations.wordpress.update_post({
id = 123,
title = "Updated Title",
status = "publish"
})
print("Updated: " .. post.title.rendered)
list_pages
List pages from the WordPress site.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
per_page | integer | no | Number of pages per page (default: 10, max: 100) |
page | integer | no | Page number (default: 1) |
search | string | no | Search term |
status | string | no | Page status (default: publish) |
author | integer | no | Filter by author user ID |
parent | integer | no | Filter by parent page ID |
order | string | no | Sort order (default: desc) |
orderby | string | no | Sort field (default: date) |
Example
local pages = app.integrations.wordpress.list_pages({
per_page = 20,
status = "publish"
})
for _, page in ipairs(pages) do
print(page.id .. ": " .. page.title.rendered)
end
list_users
List users registered on the WordPress site.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
per_page | integer | no | Number of users per page (default: 10, max: 100) |
page | integer | no | Page number (default: 1) |
search | string | no | Search by name, email, or slug |
roles | string | no | Comma-separated roles (e.g. “administrator,editor”) |
order | string | no | Sort order (default: asc) |
orderby | string | no | Sort field (default: name) |
Example
local users = app.integrations.wordpress.list_users({
roles = "administrator,editor",
per_page = 50
})
for _, user in ipairs(users) do
print(user.id .. ": " .. user.name .. " (" .. user.slug .. ")")
end
list_comments
List comments from the WordPress site.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
per_page | integer | no | Number of comments per page (default: 10, max: 100) |
page | integer | no | Page number (default: 1) |
post | integer | no | Filter by post ID |
search | string | no | Search term |
status | string | no | Comment status: approved, hold, spam, trash, any (default: approved) |
author | integer | no | Filter by comment author user ID |
order | string | no | Sort order (default: desc) |
orderby | string | no | Sort field (default: date_gmt) |
Example
local comments = app.integrations.wordpress.list_comments({
post = 123,
status = "approved",
per_page = 20
})
for _, comment in ipairs(comments) do
print(comment.author_name .. ": " .. comment.content.rendered)
end
get_current_user
Get the currently authenticated WordPress user profile. No parameters required.
Example
local user = app.integrations.wordpress.get_current_user({})
print("Logged in as: " .. user.name)
print("Roles: " .. table.concat(user.roles, ", "))Raw agent markdown
# WordPress — Lua API Reference
## list_posts
List posts from the WordPress site.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `per_page` | integer | no | Number of posts per page (default: 10, max: 100) |
| `page` | integer | no | Page number (default: 1) |
| `search` | string | no | Search term to filter by title or content |
| `status` | string | no | Post status: publish, draft, pending, private, trash, any (default: publish) |
| `author` | integer | no | Filter by author user ID |
| `categories` | string | no | Comma-separated category IDs |
| `tags` | string | no | Comma-separated tag IDs |
| `order` | string | no | Sort order: asc or desc (default: desc) |
| `orderby` | string | no | Sort field: date, title, author, id (default: date) |
### Example
```lua
local result = app.integrations.wordpress.list_posts({
per_page = 5,
status = "publish",
orderby = "date",
order = "desc"
})
for _, post in ipairs(result) do
print(post.id .. ": " .. post.title.rendered)
end
```
---
## get_post
Get a single post by ID.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The post ID |
### Example
```lua
local post = app.integrations.wordpress.get_post({ id = 123 })
print(post.title.rendered)
print(post.content.rendered)
```
---
## create_post
Create a new post. Defaults to draft status.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `title` | string | yes | Post title |
| `content` | string | no | Post content (HTML) |
| `status` | string | no | draft, publish, pending, private (default: draft) |
| `excerpt` | string | no | Post excerpt (HTML) |
| `author` | integer | no | Author user ID |
| `categories` | array | no | Array of category IDs |
| `tags` | array | no | Array of tag IDs |
| `featured_media` | integer | no | Featured image media ID |
| `slug` | string | no | URL slug (auto-generated if omitted) |
### Example
```lua
local post = app.integrations.wordpress.create_post({
title = "My New Post",
content = "<p>Hello world!</p>",
status = "draft",
categories = { 1, 5 }
})
print("Created post ID: " .. post.id)
```
---
## update_post
Update an existing post.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | Post ID to update |
| `title` | string | no | New title |
| `content` | string | no | New content (HTML) |
| `status` | string | no | New status |
| `excerpt` | string | no | New excerpt (HTML) |
| `author` | integer | no | New author user ID |
| `categories` | array | no | New category IDs (replaces existing) |
| `tags` | array | no | New tag IDs (replaces existing) |
| `featured_media` | integer | no | New featured image media ID |
| `slug` | string | no | New URL slug |
### Example
```lua
local post = app.integrations.wordpress.update_post({
id = 123,
title = "Updated Title",
status = "publish"
})
print("Updated: " .. post.title.rendered)
```
---
## list_pages
List pages from the WordPress site.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `per_page` | integer | no | Number of pages per page (default: 10, max: 100) |
| `page` | integer | no | Page number (default: 1) |
| `search` | string | no | Search term |
| `status` | string | no | Page status (default: publish) |
| `author` | integer | no | Filter by author user ID |
| `parent` | integer | no | Filter by parent page ID |
| `order` | string | no | Sort order (default: desc) |
| `orderby` | string | no | Sort field (default: date) |
### Example
```lua
local pages = app.integrations.wordpress.list_pages({
per_page = 20,
status = "publish"
})
for _, page in ipairs(pages) do
print(page.id .. ": " .. page.title.rendered)
end
```
---
## list_users
List users registered on the WordPress site.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `per_page` | integer | no | Number of users per page (default: 10, max: 100) |
| `page` | integer | no | Page number (default: 1) |
| `search` | string | no | Search by name, email, or slug |
| `roles` | string | no | Comma-separated roles (e.g. "administrator,editor") |
| `order` | string | no | Sort order (default: asc) |
| `orderby` | string | no | Sort field (default: name) |
### Example
```lua
local users = app.integrations.wordpress.list_users({
roles = "administrator,editor",
per_page = 50
})
for _, user in ipairs(users) do
print(user.id .. ": " .. user.name .. " (" .. user.slug .. ")")
end
```
---
## list_comments
List comments from the WordPress site.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `per_page` | integer | no | Number of comments per page (default: 10, max: 100) |
| `page` | integer | no | Page number (default: 1) |
| `post` | integer | no | Filter by post ID |
| `search` | string | no | Search term |
| `status` | string | no | Comment status: approved, hold, spam, trash, any (default: approved) |
| `author` | integer | no | Filter by comment author user ID |
| `order` | string | no | Sort order (default: desc) |
| `orderby` | string | no | Sort field (default: date_gmt) |
### Example
```lua
local comments = app.integrations.wordpress.list_comments({
post = 123,
status = "approved",
per_page = 20
})
for _, comment in ipairs(comments) do
print(comment.author_name .. ": " .. comment.content.rendered)
end
```
---
## get_current_user
Get the currently authenticated WordPress user profile. No parameters required.
### Example
```lua
local user = app.integrations.wordpress.get_current_user({})
print("Logged in as: " .. user.name)
print("Roles: " .. table.concat(user.roles, ", "))
``` local result = app.integrations.wordpress.create_post({title = "example_title", content = "example_content", status = "example_status", excerpt = "example_excerpt", author = 1, categories = "example_categories", tags = "example_tags", featured_media = 1})
print(result) Functions
create_post Write
Create a new post on the WordPress site. Requires a title. Content, status, categories, and tags can be specified. Defaults to draft status for safety.
- Lua path
app.integrations.wordpress.create_post- Full name
wordpress.wordpress_create_post
| Parameter | Type | Required | Description |
|---|---|---|---|
title | string | yes | The post title. |
content | string | no | The post content in HTML format. |
status | string | no | Post status: draft, publish, pending, private. Default: draft. |
excerpt | string | no | The post excerpt in HTML format. |
author | integer | no | Author user ID. Defaults to the authenticated user. |
categories | array | no | Array of category IDs to assign. |
tags | array | no | Array of tag IDs to assign. |
featured_media | integer | no | Featured image (media) ID. |
slug | string | no | URL slug for the post. Auto-generated from title if omitted. |
get_current_user Read
Get the currently authenticated WordPress user profile. Returns user ID, name, email, roles, and capabilities.
- Lua path
app.integrations.wordpress.get_current_user- Full name
wordpress.wordpress_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_post Read
Get a single WordPress post by its ID. Returns the full post object including title, content, excerpt, author, categories, tags, and metadata.
- Lua path
app.integrations.wordpress.get_post- Full name
wordpress.wordpress_get_post
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | yes | The post ID to retrieve. |
list_comments Read
List comments from the WordPress site. Supports filtering by post, status, author, and search. Returns comment IDs, content, author info, and dates.
- Lua path
app.integrations.wordpress.list_comments- Full name
wordpress.wordpress_list_comments
| Parameter | Type | Required | Description |
|---|---|---|---|
per_page | integer | no | Number of comments to return per page (default: 10, max: 100). |
page | integer | no | Page number for pagination (default: 1). |
post | integer | no | Post ID to filter comments by. |
search | string | no | Search term to filter comments by content or author. |
status | string | no | Comment status filter: approved, hold, spam, trash, or any. Default: approved. |
author | integer | no | Comment author user ID to filter by. |
order | string | no | Sort order: asc or desc (default: desc). |
orderby | string | no | Sort field: date, date_gmt, id, etc. (default: date_gmt). |
list_pages Read
List pages from the WordPress site. Supports filtering by status, author, search, and parent. Returns page IDs, titles, dates, and statuses.
- Lua path
app.integrations.wordpress.list_pages- Full name
wordpress.wordpress_list_pages
| Parameter | Type | Required | Description |
|---|---|---|---|
per_page | integer | no | Number of pages to return per page (default: 10, max: 100). |
page | integer | no | Page number for pagination (default: 1). |
search | string | no | Search term to filter pages by title or content. |
status | string | no | Page status filter: publish, draft, pending, private, or any. Default: publish. |
author | integer | no | Author user ID to filter pages by. |
parent | integer | no | Parent page ID to filter by (for hierarchical pages). |
order | string | no | Sort order: asc or desc (default: desc). |
orderby | string | no | Sort field: date, title, author, id, menu_order, etc. (default: date). |
list_posts Read
List posts from the WordPress site. Supports filtering by status, author, category, tag, and search. Returns post IDs, titles, dates, and statuses.
- Lua path
app.integrations.wordpress.list_posts- Full name
wordpress.wordpress_list_posts
| Parameter | Type | Required | Description |
|---|---|---|---|
per_page | integer | no | Number of posts to return per page (default: 10, max: 100). |
page | integer | no | Page number for pagination (default: 1). |
search | string | no | Search term to filter posts by title or content. |
status | string | no | Post status filter: publish, draft, pending, private, trash, or any. Default: publish. |
author | integer | no | Author user ID to filter posts by. |
categories | string | no | Comma-separated category IDs to filter by. |
tags | string | no | Comma-separated tag IDs to filter by. |
order | string | no | Sort order: asc or desc (default: desc). |
orderby | string | no | Sort field: date, title, author, id, etc. (default: date). |
list_users Read
List users registered on the WordPress site. Supports filtering by role and search. Returns user IDs, names, and email addresses.
- Lua path
app.integrations.wordpress.list_users- Full name
wordpress.wordpress_list_users
| Parameter | Type | Required | Description |
|---|---|---|---|
per_page | integer | no | Number of users to return per page (default: 10, max: 100). |
page | integer | no | Page number for pagination (default: 1). |
search | string | no | Search term to filter users by name, email, or slug. |
roles | string | no | Comma-separated roles to filter by (e.g. administrator, editor, author). |
order | string | no | Sort order: asc or desc (default: asc). |
orderby | string | no | Sort field: name, id, registered_date, etc. (default: name). |
update_post Write
Update an existing WordPress post. Provide the post ID and any fields to change: title, content, status, categories, tags, etc.
- Lua path
app.integrations.wordpress.update_post- Full name
wordpress.wordpress_update_post
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | yes | The post ID to update. |
title | string | no | New post title. |
content | string | no | New post content in HTML format. |
status | string | no | New post status: draft, publish, pending, private. |
excerpt | string | no | New post excerpt in HTML format. |
author | integer | no | New author user ID. |
categories | array | no | Array of category IDs to assign (replaces existing). |
tags | array | no | Array of tag IDs to assign (replaces existing). |
featured_media | integer | no | Featured image (media) ID. |
slug | string | no | New URL slug for the post. |