wordpress-api-gutenberg
Create, edit, and publish WordPress posts via REST API with full Gutenberg block support. Use when Codex needs to automate WordPress content publishing, generate articles programmatically, or manage posts through API calls. Includes authentication methods (JWT, Application Passwords), Gutenberg block serialization, featured images, categories, tags, and draft/publish workflows.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/chirukinbb/wordpress-api-gutenbergWordPress API with Gutenberg
Overview
This skill provides comprehensive guidance for interacting with WordPress REST API to create and manage posts using Gutenberg block editor format. It covers authentication, block serialization, media upload, and publishing workflows.
Quick Start
Before using the API, ensure you have:
-
WordPress site with REST API enabled (default)
-
Authentication credentials:
- Application Password (WordPress 5.6+): Generate at
/wp-admin/admin.php?page=application-passwords - JWT Authentication plugin installed (alternative)
- Username/password for Basic Auth (not recommended for production)
- Application Password (WordPress 5.6+): Generate at
-
Base URL:
https://your-site.com/wp-json/wp/v2
Authentication
Application Password (Recommended)
# Set environment variables
export WP_URL="https://your-site.com"
export WP_USERNAME="admin"
export WP_APPLICATION_PASSWORD="xxxx xxxx xxxx xxxx xxxx xxxx"
import requests
import os
wp_url = os.environ.get('WP_URL')
username = os.environ.get('WP_USERNAME')
password = os.environ.get('WP_APPLICATION_PASSWORD')
auth = (username, password)
JWT Authentication
If using JWT plugin, obtain token first:
import requests
wp_url = "https://your-site.com"
username = "admin"
password = "password"
# Get token
resp = requests.post(f"{wp_url}/wp-json/jwt-auth/v1/token",
json={"username": username, "password": password})
token = resp.json()['token']
headers = {"Authorization": f"Bearer {token}"}
Creating Posts with Gutenberg Blocks
WordPress REST API expects posts in Gutenberg's serialized block format. The content field should contain block comments and HTML.
Basic Block Structure
def create_gutenberg_post(title, content_blocks):
"""
Create a post with Gutenberg blocks.
Args:
title: Post title
content_blocks: List of block dictionaries with 'blockName' and 'attrs'
Returns:
JSON data for POST request
"""
# Serialize blocks to Gutenberg format
block_html = []
for block in content_blocks:
block_name = block.get('blockName', 'core/paragraph')
attrs = block.get('attrs', {})
inner_html = block.get('innerHTML', '')
# Create block comment
attrs_json = json.dumps(attrs) if attrs else ''
block_comment = f'<!-- wp:{block_name} {attrs_json} -->'
block_html.append(f'{block_comment}{inner_html}<!-- /wp:{block_name} -->')
content = '\n\n'.join(block_html)
return {
"title": title,
"content": content,
"status": "draft", # or "publish"
"format": "standard"
}
Common Block Examples
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-chirukinbb-wordpress-api-gutenberg": {
"enabled": true,
"auto_update": true
}
}
}