Install
openclaw skills install wp-auto-post-apiPublish SEO-optimized articles to WordPress via REST API with RankMath meta fields
openclaw skills install wp-auto-post-api通过 WordPress REST API 发布 SEO 优化文章,自动设置 RankMath Free 版 meta fields(SEO 标题、描述、焦点关键词)。
python3(无需额外 pip 依赖,仅使用标准库)functions.php 中已注册 RankMath meta keys(见下方 WordPress 配置)scripts/
├── publish_wp_article.py # 主发布脚本
docs/
├── wordpress-setup.php # functions.php 代码片段(需手动添加到 WordPress)
在 ~/.openclaw/workspace-marketing/.env 中配置:
WP_SITE_URL=https://你的域名
WP_USERNAME=WordPress用户名
WP_APP_PASSWORD=xxxx xxxx xxxx xxxx xxxx xxxx
WP_CATEGORY_ID=Articles分类的ID
cd ~/.openclaw/workspace-marketing
export $(cat .env | grep "^WP_" | xargs)
python3 skills/wp-seo-publisher/scripts/publish_wp_article.py '<json_data>'
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
title | String | ✅ | 文章标题(含关键词,50-60 字符) |
content | String | ✅ | 文章 HTML 正文(使用 H2/H3 结构) |
excerpt | String | 推荐 | 文章摘要,也用作默认 meta description |
slug | String | 推荐 | SEO 友好的 URL(英文、连字符分隔) |
focus_keyword | String | 推荐 | RankMath 焦点关键词 |
seo_title | String | 否 | 自定义 SEO 标题(留空则用 title) |
seo_description | String | 否 | 自定义 meta description(留空则用 excerpt) |
tags | Array | 否 | 标签名称列表(不存在的 tag 会自动创建) |
category_id | Number | 否 | 分类 ID(留空则用 .env 中的默认值) |
status | String | 否 | publish 或 draft(默认 draft) |
以下功能 RankMath 会根据文章内容自动处理,无需通过 API 额外设置:
| 功能 | 说明 |
|---|---|
| XML Sitemap | 新文章自动加入 sitemap,加速搜索引擎收录 |
| Canonical URL | 自动生成,防止重复内容问题 |
| Open Graph Tags | 自动生成 og:title、og:description、og:image |
| Twitter Cards | 自动生成社交分享卡片 |
| Article Schema | 自动添加 Article 结构化数据 |
| Meta Robots | 默认 index, follow |
| Breadcrumbs | 自动生成(需在 RankMath 设置中启用) |
| Meta Key | 对应 JSON 字段 | 作用 |
|---|---|---|
rank_math_title | seo_title 或 title | 搜索结果中显示的标题 |
rank_math_description | seo_description 或 excerpt | 搜索结果中显示的描述 |
rank_math_focus_keyword | focus_keyword | RankMath 内容评分的焦点关键词 |
注意:
- 关键词挖掘阶段已独立,必须委托给
seo-keyword-researcherSkill 处理。- 文章撰写与排版阶段已独立,必须委托给
seo-content-writerSkill 处理。本 Skill (
wp-seo-publisher) 仅负责「API 发布」与「日志记录」。
~/.openclaw/workspace-marketing/seo/seo_articles/,寻找并读取最新时间戳且尚未发布的 JSON 文件(例如 2026-05-06_110000.json)。status: "publish",默认以 draft 模式发布。python3 skills/wp-seo-publisher/scripts/publish_wp_article.py '<读取到的 JSON 内容>'_published 后缀(例如执行 mv 2026-05-06_110000.json 2026-05-06_110000_published.json)。memory/wp-articles-log.md。此日志仅用于本 Skill 的防重复检查和发布审计,不应被其他 Skill 用作数据输入源。{
"title": "Top 5 Benefits of Renting Robots for Corporate Events",
"content": "<h2>Why More Companies Are Choosing Robot Rental</h2><p>In today's competitive event landscape...</p><h2>1. Cost Efficiency</h2><p>Purchasing a service robot can cost...</p><h2>2. Professional Setup & Support</h2><p>When you rent from a professional provider...</p><h2>3. Cutting-Edge Technology</h2><p>Robot technology evolves rapidly...</p><h2>4. Wow Factor for Guests</h2><p>Nothing captures attention quite like...</p><h2>5. Flexibility and Variety</h2><p>Different events call for different robots...</p><h2>Ready to Elevate Your Next Event?</h2><p>Contact us today for a free consultation and quote. <a href='https://example.com/contact'>Get in touch →</a></p>",
"excerpt": "Discover the top 5 reasons why renting robots for corporate events saves money, impresses guests, and delivers cutting-edge experiences.",
"slug": "benefits-renting-robots-corporate-events",
"focus_keyword": "renting robots for corporate events",
"seo_title": "Top 5 Benefits of Renting Robots for Corporate Events | Your Company",
"seo_description": "Discover the top 5 reasons why renting robots for corporate events saves money, impresses guests, and delivers cutting-edge experiences.",
"tags": ["robot rental", "corporate events", "service robots", "event technology"],
"status": "draft"
}
## 2026-05-07
- **Title**: Top 5 Benefits of Renting Robots for Corporate Events
- **URL**: https://example.com/benefits-renting-robots-corporate-events/
- **Focus Keyword**: renting robots for corporate events
- **Tags**: robot rental, corporate events, service robots, event technology
- **Status**: published
docs/wordpress-setup.php 中的代码添加到主题 functions.php成功时输出:
✅ Article published successfully!
Post ID: 123
URL: https://example.com/your-article-slug/
Status: publish
Focus Keyword: your keyword
__RESULT_JSON__:{"success":true,"post_id":123,"url":"...","status":"publish",...}
失败时返回非零退出码,并输出错误信息。
status: "draft" 测试,在 WordPress 后台确认 RankMath 数据正确