当前位置: 首页 > Skill >

WordPress

WordPress

1.0.2 2026.11.26 浏览:767
获取Skill文件查看使用说明
作者:陈澄许可证:
本文目录展开

WordPress.com

Access the WordPress.com REST API with managed OAuth authentication. Create and manage posts, pages, and site content on WordPress.com hosted sites.

Quick Start

# List posts from a site
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/wordpress/rest/v1.1/sites/{site_id}/posts?number=10')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

Base URL

https://api.maton.ai/wordpress/rest/v1.1/{endpoint}

Maton proxies requests to public-api.wordpress.com and automatically injects your OAuth token.

Note: WordPress.com uses the REST v1.1 API. Site-specific endpoints use the pattern /sites/{site_id_or_domain}/{resource}.

Authentication

All requests require the Maton API key in the Authorization header:

Authorization: Bearer $MATON_API_KEY

Environment Variable: Set your API key as MATON_API_KEY:

export MATON_API_KEY="YOUR_API_KEY"

Getting Your API Key

  1. Sign in or create an account at maton.ai
  2. Go to maton.ai/settings
  3. Copy your API key

Connection Management

Manage your WordPress.com OAuth connections at https://api.maton.ai.

List Connections

python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/connections?app=wordpress&status=ACTIVE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

Create Connection

python <<'EOF'
import urllib.request, os, json
data = json.dumps({'app': 'wordpress'}).encode()
req = urllib.request.Request('https://api.maton.ai/connections', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

Get Connection

python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/connections/{connection_id}')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

Response:

{
  "connection": {
    "connection_id": "{connection_id}",
    "status": "ACTIVE",
    "creation_time": "2026-02-10T07:46:26.908898Z",
    "last_updated_time": "2026-02-10T07:49:33.440422Z",
    "url": "https://connect.maton.ai/?session_token=...",
    "app": "wordpress",
    "metadata": {}
  }
}

Open the returned url in a browser to complete OAuth authorization.

Delete Connection

python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/connections/{connection_id}', method='DELETE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

Specifying Connection

If you have multiple WordPress.com connections, specify which one to use with the Maton-Connection header:

python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/wordpress/rest/v1.1/sites/{site_id}/posts')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Maton-Connection', '{connection_id}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

If you have multiple connections, always include this header to ensure requests go to the intended account.

Security & Permissions

  • Access is scoped to posts, pages, sites, and content within the connected WordPress.com account.
  • All write operations require explicit user approval. Before executing any create, update, or delete call, confirm the target resource and intended effect with the user.

API Reference

Sites

Get Site Information

GET /wordpress/rest/v1.1/sites/{site_id_or_domain}

Response:

{
  "ID": 252505333,
  "name": "My Blog",
  "description": "Just another WordPress.com site",
  "URL": "https://myblog.wordpress.com",
  "capabilities": {
    "edit_pages": true,
    "edit_posts": true,
    "edit_others_posts": true,
    "delete_posts": true
  }
}

The site identifier can be either:

  • Numeric site ID (e.g., 252505333)
  • Domain name (e.g., myblog.wordpress.com or en.blog.wordpress.com)

Posts

List Posts

GET /wordpress/rest/v1.1/sites/{site}/posts

Query Parameters:

  • number - Number of posts to return (default: 20, max: 100)
  • offset - Offset for pagination
  • page - Page number
  • page_handle - Cursor for pagination (from response meta.next_page)
  • order - Sort order: DESC or ASC
  • order_by - Sort field: date, modified, title, comment_count, ID
  • status - Post status: publish, draft, pending, private, future, trash, any
  • type - Post type: post, page, any
  • search - Search term
  • category - Category slug
  • tag - Tag slug
  • author - Author ID
  • fields - Comma-separated list of fields to return

Response:

{
  "found": 150,
  "posts": [
    {
      "ID": 83587,
      "site_ID": 3584907,
      "author": {
        "ID": 257479511,
        "login": "username",
        "name": "John Doe"
      },
      "date": "2026-02-09T15:00:00+00:00",
      "modified": "2026-02-09T16:30:00+00:00",
      "title": "My Post Title",
      "excerpt": "<p>Post excerpt...</p>",
      "content": "<p>Full post content...</p>",
      "slug": "my-post-title",
      "status": "publish",
      "type": "post",
      "categories": {...},
      "tags": {...}
    }
  ],
  "meta": {
    "next_page": "value=2026-02-09T15%3A00%3A00%2B00%3A00&id=83587"
  }
}

Get Post

GET /wordpress/rest/v1.1/sites/{site}/posts/{post_id}

Response:

{
  "ID": 83587,
  "site_ID": 3584907,
  "author": {...},
  "date": "2026-02-09T15:00:00+00:00",
  "title": "My Post Title",
  "content": "<p>Full post content...</p>",
  "slug": "my-post-title",
  "status": "publish",
  "type": "post",
  "categories": {
    "news": {
      "ID": 123,
      "name": "News",
      "slug": "news"
    }
  },
  "tags": {
    "featured": {
      "ID": 456,
      "name": "Featured",
      "slug": "featured"
    }
  }
}

Create Post

POST /wordpress/rest/v1.1/sites/{site}/posts/new
Content-Type: application/json

{
  "title": "New Post Title",
  "content": "<p>Post content here...</p>",
  "status": "draft",
  "categories": "news, updates",
  "tags": "featured, important"
}

Parameters:

  • title - Post title (required)
  • content - Post content (HTML)
  • excerpt - Post excerpt
  • status - publish, draft, pending, private, future
  • date - Post date (ISO 8601)
  • categories - Comma-separated category names or slugs
  • tags - Comma-separated tag names or slugs
  • format - Post format: standard, aside, chat, gallery, link, image, quote, status, video, audio
  • slug - URL slug
  • featured_image - Featured image attachment ID
  • sticky - Whether post is sticky (boolean)
  • password - Password to protect post

Response:

{
  "ID": 123,
  "site_ID": 252505333,
  "title": "New Post Title",
  "status": "draft",
  "date": "2026-02-10T09:50:35+00:00"
}

Update Post

POST /wordpress/rest/v1.1/sites/{site}/posts/{post_id}
Content-Type: application/json

{
  "title": "Updated Title",
  "content": "<p>Updated content...</p>"
}

Uses the same parameters as Create Post.

Delete Post

POST /wordpress/rest/v1.1/sites/{site}/posts/{post_id}/delete

Moves post to trash. Returns the deleted post with status: "trash".

Pages

Pages use the same endpoints as posts with type=page:

List Pages

GET /wordpress/rest/v1.1/sites/{site}/posts?type=page

Create Page

POST /wordpress/rest/v1.1/sites/{site}/posts/new?type=page
Content-Type: application/json

{
  "title": "About Us",
  "content": "<p>About page content...</p>",
  "status": "publish"
}

Get Page Dropdown List

GET /wordpress/rest/v1.1/sites/{site}/dropdown-pages/

Returns a simplified list of pages for dropdowns/menus.

Get Page Templates

GET /wordpress/rest/v1.1/sites/{site}/page-templates

Returns available page templates for the site's theme.

Post Likes

Get Post Likes

GET /wordpress/rest/v1.1/sites/{site}/posts/{post_id}/likes

Response:

{
  "found": 99,
  "i_like": false,
  "can_like": true,
  "site_ID": 3584907,
  "post_ID": 83587,
  "likes": [...]
}

Like Post

POST /wordpress/rest/v1.1/sites/{site}/posts/{post_id}/likes/new

Unlike Post

POST /wordpress/rest/v1.1/sites/{site}/posts/{post_id}/likes/mine/delete

Post Reblogs

Check Reblog Status

GET /wordpress/rest/v1.1/sites/{site}/posts/{post_id}/reblogs/mine

Response:

{
  "can_reblog": true,
  "can_user_reblog": true,
  "is_reblogged": false
}

Post Types

List Post Types

GET /wordpress/rest/v1.1/sites/{site}/post-types

Response:

{
  "found": 3,
  "post_types": {
    "post": {
      "name": "post",
      "label": "Posts",
      "labels": {...}
    },
    "page": {
      "name": "page",
      "label": "Pages",
      "labels": {...}
    }
  }
}

Post Counts

Get Post Counts

GET /wordpress/rest/v1.1/sites/{site}/post-counts/{post_type}

Example: /sites/{site}/post-counts/post or /sites/{site}/post-counts/page

Response:

{
  "counts": {
    "all": {"count": 150},
    "publish": {"count": 120},
    "draft": {"count": 25},
    "trash": {"count": 5}
  }
}

Users

List Site Users

GET /wordpress/rest/v1.1/sites/{site}/users

Response:

{
  "found": 3,
  "users": [
    {
      "ID": 277004271,
      "login": "username",
      "name": "John Doe",
      "email": "john@example.com",
      "roles": ["administrator"]
    }
  ]
}

User Settings

Get User Settings

GET /wordpress/rest/v1.1/me/settings

Response:

{
  "enable_translator": true,
  "surprise_me": false,
  "holidaysnow": false,
  "user_login": "username"
}

Update User Settings

POST /wordpress/rest/v1.1/me/settings/
Content-Type: application/json

{
  "enable_translator": false
}

User Likes

Get User's Liked Posts

GET /wordpress/rest/v1.1/me/likes

Response:

{
  "found": 10,
  "likes": [
    {
      "ID": 83587,
      "site_ID": 3584907,
      "title": "Liked Post Title"
    }
  ]
}

Embeds

Get Site Embeds

GET /wordpress/rest/v1.1/sites/{site}/embeds

Returns available embed handlers for the site.

Shortcodes

Get Available Shortcodes

GET /wordpress/rest/v1.1/sites/{site}/shortcodes

Returns shortcodes available on the site.

Pagination

WordPress.com uses cursor-based pagination with page_handle:

import os
import requests

headers = {
    'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}'
}

# Initial request
response = requests.get(
    'https://api.maton.ai/wordpress/rest/v1.1/sites/{site}/posts',
    headers=headers,
    params={'number': 20}
)
result = response.json()
all_posts = result['posts']

# Continue with page_handle
while result.get('meta', {}).get('next_page'):
    response = requests.get(
        'https://api.maton.ai/wordpress/rest/v1.1/sites/{site}/posts',
        headers=headers,
        params={'number': 20, 'page_handle': result['meta']['next_page']}
    )
    result = response.json()
    all_posts.extend(result['posts'])

print(f"Total posts: {len(all_posts)}")

Alternatively, use offset for simple pagination:

GET /wordpress/rest/v1.1/sites/{site}/posts?number=20&offset=20

Code Examples

JavaScript

const response = await fetch(
  'https://api.maton.ai/wordpress/rest/v1.1/sites/{site}/posts?number=10',
  {
    headers: {
      'Authorization': `Bearer ${process.env.MATON_API_KEY}`
    }
  }
);
const data = await response.json();
console.log(`Found ${data.found} posts`);

Python

import os
import requests

response = requests.get(
    'https://api.maton.ai/wordpress/rest/v1.1/sites/{site}/posts',
    headers={'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}'},
    params={'number': 10, 'status': 'publish'}
)
data = response.json()
print(f"Found {data['found']} posts")

Python (Create Post)

import os
import requests

response = requests.post(
    'https://api.maton.ai/wordpress/rest/v1.1/sites/{site}/posts/new',
    headers={
        'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}',
        'Content-Type': 'application/json'
    },
    json={
        'title': 'My New Post',
        'content': '<p>Hello World!</p>',
        'status': 'draft',
        'categories': 'news',
        'tags': 'hello, first-post'
    }
)
post = response.json()
print(f"Created post ID: {post['ID']}")

Notes

  • WordPress.com API uses REST v1.1 (not v2)
  • Site identifiers can be numeric IDs or domain names
  • POST requests to /posts/{id} update the post (not PUT/PATCH)
  • DELETE uses POST to /posts/{id}/delete (not HTTP DELETE)
  • Categories and tags are created automatically when referenced in posts
  • Date/time values are in ISO 8601 format
  • All content is HTML-formatted
  • IMPORTANT: When piping curl output to jq or other commands, environment variables like $MATON_API_KEY may not expand correctly in some shell environments

Error Handling

Status Meaning
400 Missing WordPress connection or bad request
401 Invalid or missing Maton API key
403 Insufficient permissions or OAuth scope
404 Site or resource not found
429 Rate limited
4xx/5xx Passthrough error from WordPress.com API

Error responses include details:

{
  "error": "unauthorized",
  "message": "User cannot view users for specified site"
}

Troubleshooting: API Key Issues

  1. Check that the MATON_API_KEY environment variable is set:
echo $MATON_API_KEY
  1. Verify the API key is valid by listing connections:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/connections')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

Troubleshooting: Invalid App Name

  1. Ensure your URL path starts with wordpress. For example:
  • Correct: https://api.maton.ai/wordpress/rest/v1.1/sites/{site_id}/posts
  • Incorrect: https://api.maton.ai/rest/v1.1/sites/{site_id}/posts

Resources

  • WordPress.com REST API Overview
  • Getting Started Guide
  • API Reference
  • OAuth Authentication
  • Maton Community
  • Maton Support

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,031
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,029
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,017
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,014
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,011
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,011
Skill 文件
  • SKILL.md
    • WordPress.com
    • Quick Start
    • Base URL
    • Authentication
      • Getting Your API Key
    • Connection Management
      • List Connections
      • Create Connection
      • Get Connection
      • Delete Connection
      • Specifying Connection
    • Security & Permissions
    • API Reference
      • Sites
        • Get Site Information
      • Posts
        • List Posts
        • Get Post
        • Create Post
        • Update Post
        • Delete Post
      • Pages
        • List Pages
        • Create Page
        • Get Page Dropdown List
        • Get Page Templates
      • Post Likes
        • Get Post Likes
        • Like Post
        • Unlike Post
      • Post Reblogs
        • Check Reblog Status
      • Post Types
        • List Post Types
      • Post Counts
        • Get Post Counts
      • Users
        • List Site Users
      • User Settings
        • Get User Settings
        • Update User Settings
      • User Likes
        • Get User's Liked Posts
      • Embeds
        • Get Site Embeds
      • Shortcodes
        • Get Available Shortcodes
    • Pagination
    • Code Examples
      • JavaScript
      • Python
      • Python (Create Post)
    • Notes
    • Error Handling
      • Troubleshooting: API Key Issues
      • Troubleshooting: Invalid App Name
    • Resources
  • 项目或源文件

相关 Skill

更多
Wordpress AEO Autoblogger Wordpress AEO Autoblogger 自主AEO与SEO内容生成与优化引擎,用于规模化业务运营。适用于Codex需执行端到端程序化SEO的场景。
WordPress REST API CLI WordPress REST API CLI OpenClaw 技能,提供 WordPress REST API 命令行接口,用于文章、页面、分类、标签、用户及自定义请求,使用纯 HTTP。
wordpress-ultimate wordpress-ultimate Three env vars. One script. Your agent manages your entire WordPress site — draft-only safety included.
Develop and harden WordPress plugins with lifecycle and security guardrails Develop and harden WordPress plugins with lifecycle and security guardrails 当代理需要构建、重构、保护或打包具有正确激活钩子、设置处理、卸载行为和数据卫生的WordPress插件时,请使用Automattic官方wp-plugin-development技能。这是一个插件工程手册,而不是通用的WordPress列表。
WordPress MCP WordPress MCP 通过AI Engine的MCP(模型上下文协议)管理WordPress网站。用于创建/编辑文章、SEO分析、数据分析、媒体管理、分类操作、社媒排程、多语言内容(Polylang)及任何WordPress管理任务。需安装免费AI Engine插件并启用MCP服务器。适用于WordPress网站管理、内容工作流或WP相关任务。