Publish content directly to WordPress sites using the REST API with full Gutenberg block formatting, automatic category selection, SEO tag generation, and preview capabilities.
Complete Workflow Overview
1. CONNECT → Authenticate with WordPress site
ANALYZE → Load categories from site, analyze content for best match
GENERATE → Create SEO-optimized tags based on content
CONVERT → Transform markdown/HTML to Gutenberg blocks
PREVIEW → Create draft and verify rendering
PUBLISH → Publish or schedule the post
VERIFY → Confirm live post renders correctly
Step 1: Connection Setup
Get Credentials
Ask user for:
WordPress site URL (e.g., https://example.com)
WordPress username
Application password (NOT regular password)
How to Create Application Password
Guide user:
Go to Users → Profile in WordPress admin
Scroll to Application Passwords section
Enter name: Claude Publisher
Click Add New Application Password
Copy the generated password (shown only once, with spaces)
Test Connection
from scripts.wp_publisher import WordPressPublisher
The system analyzes content and selects the most appropriate category:
# Analyze content and suggest best category
suggested_category = wp.suggest_category(
content=article_content,
title=article_title,
available_categories=categories
)
# Or let user choose from available options
print("Available categories:")
for cat in categories:
print(f" [{cat['id']}] {cat['name']} ({cat['count']} posts)")
Category Selection Logic
Exact match - Title/content contains category name
Keyword match - Category slug matches topic keywords
Parent category - Fall back to broader parent if no match
Create new - Create category if none fit (with user approval)
Step 3: Generate SEO-Optimized Tags
Automatic Tag Generation
Generate tags that improve Google search visibility:
# Generate tags based on content analysis
tags = wp.generate_seo_tags(
content=article_content,
title=article_title,
max_tags=10
)
Tables are converted with proper Gutenberg structure:
# Input markdown:
Feature
Plan A
Plan B
Price
$10
$20
# Output Gutenberg:
Feature
Plan A
Plan B
Price
$10
$20
Step 5: Preview Before Publishing
Create Draft for Preview
# Create as draft first
result = wp.create_draft(
title="Article Title",
content=gutenberg_content,
categories=[category_id],
tags=tag_ids,
excerpt="Auto-generated or custom excerpt"
)
# Fetch preview page to verify rendering
preview_content = wp.fetch_preview(post_id)
# Check for issues
issues = wp.validate_rendered_content(preview_content)
if issues:
print("Issues found:")
for issue in issues:
print(f" - {issue}")
Preview Checklist
[ ] Title displays correctly
[ ] All headings render (H2, H3, H4)
[ ] Tables render with proper formatting
[ ] Lists display correctly (bullet and numbered)
[ ] Code blocks have syntax highlighting
[ ] Images load (if any)
[ ] Links are clickable
[ ] Category shows correctly
[ ] Tags display in post
Step 6: Publish the Post
Publish Draft
# After preview approval, publish
result = wp.publish_post(post_id)
live_url = result['live_url']
Or Create and Publish Directly
# Full publish workflow in one call
result = wp.publish_content(
title="Article Title",
content=gutenberg_content,
category_names=["Cloud Hosting"], # By name, auto-resolves to ID
tag_names=["n8n", "hosting", "automation"],
status="publish", # or "draft", "pending", "private", "future"
excerpt="Custom excerpt for SEO",
slug="custom-url-slug"
)
Scheduling Posts
# Schedule for future publication
from datetime import datetime, timedelta