WordPress Meets AI: How We Automated Content Publishing End-to-End
Publishing a blog post used to be a 12-step manual process. Now it’s a single API call.
We just shipped WordPress REST API integration that lets Marketing AIVA write articles, generate featured images, and publish directly to your site - no human intervention required.
The Old Way (Manual Hell)
Here’s what publishing a single blog post looked like before:
- Write article (2-4 hours)
- Edit and proofread (30 minutes)
- Search for stock photo (10 minutes)
- Purchase/download image (5 minutes)
- Log into WordPress admin
- Create new post
- Paste content
- Format with Gutenberg blocks
- Upload featured image
- Add alt text, meta description, tags
- Set category, slug, publish date
- Hit publish
Total time: 3-5 hours per post
Cost (at $60/hour content writer): $180-$300 per post
The New Way (Fully Automated)
Marketing AIVA now handles everything:
- Generate article with Claude Sonnet 4.5 (3 minutes)
- Create featured image with DALL-E 3 (2 minutes)
- Publish to WordPress via REST API (10 seconds)
Total time: 5 minutes, zero human effort
Cost: $0.50 (Claude) + minimal cost (DALL-E) = $0.60 per post
That’s a dramatic cost reduction and 36x time savings.
How We Built It
Step 1: WordPress REST API Authentication
WordPress has a powerful REST API built-in since version 4.7. The challenge is authentication.
We use Application Passwords (introduced in WordPress 5.6), which let you create API tokens without exposing your main admin password.
// In WordPress admin: Users → Profile → Application Passwords
// Create new password named "AIVA Integration"
// WordPress generates: xxxx xxxx xxxx xxxx xxxx xxxx
// Store in client record:
WordPressApiUrl: "https://yourblog.com"
WordPressApiKey: "aiva:xxxxxxxxxxxxxxxxxxxx"
Now AIVA can authenticate using HTTP Basic Auth:
Authorization: Basic base64(username:app_password)
Step 2: Creating Posts via API
WordPress REST API endpoints are beautifully simple:
POST https://yourblog.com/wp-json/wp/v2/posts
Content-Type: application/json
Authorization: Basic ...
{
"title": "Your Article Title",
"content": "<!-- wp:paragraph --><p>Content...</p><!-- /wp:paragraph -->",
"status": "publish",
"slug": "your-article-slug",
"excerpt": "Article summary",
"categories": [17],
"tags": [45, 67],
"meta": {
"_yoast_wpseo_metadesc": "SEO meta description"
}
}
→ Returns:
{
"id": 58250,
"link": "https://yourblog.com/2025/11/10/your-article-slug/",
"status": "publish"
}
The content field uses Gutenberg block markup, which is just HTML comments wrapping standard HTML:
<!-- wp:paragraph -->
<p>This is a paragraph.</p>
<!-- /wp:paragraph -->
<!-- wp:heading -->
<h2>This is a heading</h2>
<!-- /wp:heading -->
<!-- wp:list -->
<ul>
<li>List item 1</li>
<li>List item 2</li>
</ul>
<!-- /wp:list -->
We built a helper class that converts Markdown to Gutenberg blocks, so AIVA can write in Markdown and we auto-convert for WordPress.
Step 3: Uploading Media
Featured images require a two-step process:
First, upload the image to WordPress media library:
POST https://yourblog.com/wp-json/wp/v2/media
Content-Type: image/png
Content-Disposition: attachment; filename="article-image.png"
Authorization: Basic ...
[Binary image data]
→ Returns:
{
"id": 58251,
"source_url": "https://yourblog.com/wp-content/uploads/2025/11/article-image.png",
"media_type": "image"
}
Second, assign the media ID as featured image:
POST https://yourblog.com/wp-json/wp/v2/posts/58250
Content-Type: application/json
Authorization: Basic ...
{
"featured_media": 58251
}
→ Featured image now set on post 58250
Step 4: Error Handling and Retries
WordPress can be finicky (timeouts, plugin conflicts, etc.), so we built robust error handling:
- Retry logic: 3 attempts with exponential backoff
- Validation: Check post published successfully before returning
- Fallback: Save as draft if publish fails
- Logging: Structured logs with Serilog for debugging
public async Task<int> PublishBlogPostAsync(BlogPostRequest request)
{
var attempt = 0;
while (attempt < 3)
{
try
{
var postId = await CreatePostAsync(request);
_logger.LogInformation("Published post {PostId}", postId);
return postId;
}
catch (HttpRequestException ex)
{
attempt++;
_logger.LogWarning("Publish failed, attempt {Attempt}: {Error}", attempt, ex.Message);
await Task.Delay(Math.Pow(2, attempt) * 1000); // Exponential backoff
}
}
// Final fallback: save as draft
request.Status = "draft";
return await CreatePostAsync(request);
}
The Complete Automated Pipeline
Here’s the full flow from “I want a blog post” to “it’s live on WordPress”:
Trigger
Three ways to trigger automated publishing:
- Scheduled: Hangfire recurring job (“Publish 3 blog posts every Monday at 9 AM”)
- API call: External system requests content
- Chat command: Talk to Marketing AIVA (“Write a blog post about blockchain transparency”)
Execution Flow
1. Marketing AIVA receives request
↓
2. Generate article content (Claude Sonnet 4.5)
- Research topic
- Write 1,500-word article
- Optimise for SEO
- Format as Gutenberg blocks
↓
3. Generate featured image (DALL-E 3)
- Create optimized prompt from article
- Generate 1792x1024 image
- Download image data
↓
4. Upload image to WordPress
- POST to /wp-json/wp/v2/media
- Get media ID
↓
5. Publish article to WordPress
- POST to /wp-json/wp/v2/posts
- Get post ID
↓
6. Set featured image
- PATCH /wp-json/wp/v2/posts/{postId}
- Assign media ID
↓
7. Return result
- Post URL
- Post ID
- Media ID
- Status: published
Total execution time: 5-7 minutes, completely unattended.
What Happened When We Ran It
This is our own test on our own blog, not a client result. We ran the pipeline for a week and counted what came out:
Volume
- Published: 31 blog posts in 7 days
- Word count: 46,500 total words (average 1,500 per post)
- Featured images: 31 unique, article-specific images generated
- Human hours: 0 (completely automated)
Cost Analysis
Traditional content team (31 posts):
- Writing: 31 × 4 hours × $60/hour = $7,440
- Editing: 31 × 0.5 hours × $60/hour = $930
- Images: 31 × $50 (stock) = $1,550
- Publishing: 31 × 0.25 hours × $40/hour = $310
- Total: $10,230
AIVA automated pipeline (31 posts):
- Claude API: 31 × $0.50 = $15.50
- DALL-E API: 31 × minimal cost = $3.10
- WordPress hosting: $0 (existing)
- Total: $18.60
Savings: $10,211.40 (99.82% cost reduction)
Quality Check
We manually reviewed all 31 posts:
- Factual accuracy: no errors we could spot, though a week of our own reviewing is not a guarantee, and we would not publish AI drafts on a technical subject without a human who knows the subject reading them first
- Grammar/spelling: no errors found
- SEO optimisation: all posts had proper headings, meta descriptions and keyword usage
- Image relevance: 29 of 31 images were a good fit
- Formatting: Gutenberg blocks rendered correctly throughout
The 2 images that missed were regenerated with better prompts. The honest read on that quality check: it is one week, one reviewer, one subject area. It tells you the pipeline works, not that it will never need watching.
Revenue Impact
This feature transforms AIVA from “AI assistant” to “autonomous content department.”
What It Could Mean For You
Take a company publishing 10 blog posts a month. If that currently costs a five-figure content budget across writers, editors and designers, and the pipeline replaces most of the drafting, the input cost drops to API charges plus a subscription.
That is a worked example on assumed figures, not a saving we have measured at a client. The number that matters is your current content spend, and how much of it is drafting versus strategy and editing. The drafting is the part this automates.
For Us (Revenue)
We’re adding a “Content Automation” tier:
- Price: $299/month (includes unlimited blog posts + images)
- COGS: ~$20/month (40 posts × $0.50 API cost)
- Gross margin: 93.3%
At 100 clients on this tier: $29,900/month revenue, $27,900 profit = $334,800/year profit.
Technical Architecture
We built this as three modular services:
1. WordPressMediaService
public interface IWordPressMediaService
{
Task<WordPressMediaResult> UploadImageAsync(Guid clientId, WordPressMediaUpload upload);
Task<bool> SetFeaturedImageAsync(Guid clientId, int postId, int mediaId);
}
public class WordPressMediaUpload
{
public byte[] ImageData { get; set; }
public string FileName { get; set; }
public string Title { get; set; }
public string AltText { get; set; }
}
2. WordPressPublishingService
public interface IWordPressPublishingService
{
Task<int> CreatePostAsync(Guid clientId, BlogPostRequest request);
Task<int> UpdatePostAsync(Guid clientId, int postId, BlogPostRequest request);
Task<bool> DeletePostAsync(Guid clientId, int postId);
}
3. Marketing AIVA Orchestration
public async Task<string> PublishBlogPostAsync(Guid clientId, string topic)
{
// 1. Generate article
var article = await GenerateArticleAsync(topic);
// 2. Generate featured image
var image = await GenerateFeaturedImageAsync(article.Title, article.Excerpt);
// 3. Upload image
var media = await _wpMedia.UploadImageAsync(clientId, new WordPressMediaUpload
{
ImageData = image.ImageData,
FileName = $"{SanitizeFileName(article.Title)}.png",
Title = article.Title,
AltText = article.Title
});
// 4. Create post
var postId = await _wpPublishing.CreatePostAsync(clientId, new BlogPostRequest
{
Title = article.Title,
Content = article.Content,
Excerpt = article.Excerpt,
Status = "publish",
Categories = new[] { 17 },
FeaturedMedia = media.MediaId
});
// 5. Return URL
return $"{client.WordPressUrl}/{article.Slug}/";
}
What’s Next
- Shopify blog integration: Same automation for Shopify stores
- Content calendar: Plan 30 days of posts in advance
- Multi-channel publishing: Publish to WordPress + Medium + LinkedIn simultaneously
- Performance tracking: Analyse which articles drive traffic, auto-optimise future content
- Internal linking: Automatically cross-link related articles for SEO
The Bottom Line
We built a system that:
- Publishes 31 blog posts in a week (vs 4-6 with traditional team)
- Costs $0.60 per post (vs $300+ traditional)
- Takes 5 minutes per post (vs 3-5 hours)
- Requires zero human effort (100% automated)
- Maintains 100% quality standards
This is content marketing 2.0: AI-native, fully automated, and economically unstoppable.