Publishing to WordPress with Claude and the WordPress MCP Connector

AI Productivity · Claude · WordPress MCP

Publishing to WordPress with Claude and the WordPress MCP Connector

A practical guide to using Claude on claude.ai to draft, style, and publish blog posts directly to your WordPress site — with hard-won lessons on what WordPress strips, and how to work around it.

Several posts on this blog — including Word Embeddings Explained, SingIDBot, and the OpenClaw Telegram integration guide — were written, styled, and published entirely through Claude on claude.ai, using the WordPress MCP connector. This post documents exactly how that workflow operates, what problems arise, and how to resolve them.

The combination of Claude’s HTML generation capability and the WordPress MCP connector creates a surprisingly smooth authoring pipeline, provided you know the constraints WordPress imposes on custom HTML blocks. Those constraints are the non-obvious part, and they are addressed in detail below.

1. Prerequisites

Before you begin, the following need to be in place:

Requirement Details
Claude account on claude.ai Free tier works; a Pro account gives longer contexts useful for large HTML posts.
WordPress.com site The MCP connector works with WordPress.com-hosted blogs. Self-hosted WordPress.org sites are not directly supported by the connector.
WordPress MCP connector enabled In claude.ai, go to Settings → Integrations (or Connectors) and enable the WordPress.com connector. Authenticate with your WordPress.com account.

2. The Overall Workflow

The end-to-end process has three stages. Claude handles all of them in a single conversation.

Stage 1

Draft & Style

Provide Claude with your content and request a WordPress HTML block with inline CSS only. No <style> tags.

Stage 2

Review Output

Preview the rendered HTML in claude.ai artifacts. Request edits until the post looks correct.

Stage 3

Publish via MCP

Ask Claude to post using the WordPress connector. It checks categories and tags, creates any missing ones, then submits as a draft for your review.

The key prompt to kick off Stage 1:

“Generate a WordPress post using a custom HTML block with inline CSS only. Do not use <style> tags, <script> tags, or SVG.”

For Stage 3, once the HTML is finalised:

“Post this to malcolmlow.net using the WordPress connector. Use appropriate categories and tags. Post as a draft first.”

3. How the WordPress MCP Connector Works

The MCP (Model Context Protocol) connector gives Claude direct access to your WordPress.com REST API. When you ask Claude to post, it performs these operations internally:

  1. Loads the connector via an internal tool search, resolving the WordPress.com:wpcom-mcp-content-authoring tool.
  2. Lists existing categories using categories.list on your site to find IDs for any categories you want.
  3. Lists existing tags using tags.list to find or create the tags for the post.
  4. Creates missing categories or tags using categories.create / tags.create if they do not already exist on the site.
  5. Creates the post using posts.create, passing the HTML content, title, category IDs, tag IDs, and status (draft or publish).
  6. Returns the preview and edit URLs so you can open the draft in WordPress immediately.

The post content must be wrapped in a wp:html block comment:

<!– wp:html –>
  <div style=”…”>…post content…</div>
<!– /wp:html –>

4. Problems Encountered — and How They Were Solved

The workflow is productive but not without friction. Several issues emerged across multiple posts on this blog. Each is documented here with its root cause and fix.

Problem 1: WordPress strips <style> blocks entirely

What happened: Early posts were written with a <style> tag at the top of the HTML block, defining CSS classes such as .matrix-bracket for rendering quantum circuit diagrams in the Grover’s Algorithm post. When the post was saved and previewed in WordPress, all styling vanished — the <style> block was silently removed by WordPress’s content sanitisation.

Fix: Every CSS rule must be written as an inline style="..." attribute on the element it targets. No exceptions. Claude handles this when explicitly instructed: “Use inline CSS only. Do not use <style> tags.”

Problem 2: WordPress strips SVG elements

What happened: Posts in the quantum computing series used inline SVG to draw circuit gate diagrams. WordPress stripped all <svg> tags on save, leaving blank spaces where diagrams should have appeared.

Fix: Replace SVG diagrams with Unicode box-drawing characters and monospace <pre> or <div> elements with font-family: 'Courier New', monospace applied inline. The instruction to Claude: “Do not use SVG. Use Unicode and monospace divs for all diagrams.”

Problem 3: <script> tags are blocked

What happened: Attempts to add interactive elements via JavaScript were silently discarded. WordPress removes <script> tags from Custom HTML blocks for security reasons.

Fix: All interactivity must be replaced with pure HTML/CSS alternatives. Claude’s default behaviour now includes “no <script> tags” as a standing instruction for all WordPress posts.

Problem 4: API parameter case sensitivity

What happened: Passing "order": "DESC" (uppercase) to the posts.list operation returned a validation error: “order is not one of asc and desc.”

Fix: The WordPress.com REST API enforces lowercase values for enumerated parameters. Always use "order": "desc" in API calls.

Problem 5: Duplicate categories and tags

What happened: Without checking first, Claude created duplicate taxonomy terms — a “Python” category appeared twice under slightly different capitalisation.

Fix: Claude’s posting workflow now always calls categories.list and tags.list before any creation step. Only genuinely new terms are created.

Tip: Let Claude Choose Categories and Tags Automatically

You do not need to specify categories and tags manually. Simply ask Claude to “use appropriate categories and tags” and it will inspect the existing taxonomy on your site, infer suitable terms from the post content, and create any new ones that are genuinely needed. This works well for most posts and saves the step of looking up category IDs yourself.

5. Step-by-Step: Posting via Claude and WordPress MCP

The following steps reproduce the exact workflow used to create and publish posts on this blog.

Step 1 — Enable the WordPress Connector in claude.ai

Go to claude.ai → Settings → Integrations. Find the WordPress.com connector and click Connect. Authorise it with your WordPress.com account. Once connected, the connector appears as an available tool in all your conversations.

Step 2 — Prepare your content and prompt Claude

Provide Claude with the raw content, a reference post URL for style matching, and the constraint set:

Generate a WordPress post as a custom HTML block.
Use inline CSS only — no <style> tags, no <script> tags, no SVG.
Match the styling of: [URL of a reference post]
Topic: [your content here]

Step 3 — Review the artifact in claude.ai

Claude renders the HTML in an artifact panel. Review layout, colours, code block rendering, and table formatting. Verify that no <style> or <script> tags appear in the source.

Step 4 — Trigger the WordPress MCP posting

Once the HTML is finalised:

Post this to myhlow.wordpress.com using the WordPress connector.
Use appropriate categories and tags.
Status: draft

Claude will call categories.list and tags.list, create any missing terms, then execute posts.create and return the draft edit and preview URLs.

Step 5 — Preview in WordPress and publish

Open the draft URL Claude returns. If the Custom HTML block renders correctly, click Publish. If styling is missing, return to the conversation and ask Claude to convert any remaining CSS classes to inline attributes.

6. Quick Reference: Dos and Don’ts

Do Don’t
Use style="..." on every element Use <style> blocks or CSS classes
Use Unicode and monospace divs for diagrams Use <svg> elements inline
Wrap content in <!-- wp:html --> Use <script> tags for interactivity
Use lowercase "order": "desc" in API params Use uppercase "order": "DESC"
Post as draft first and preview in WordPress Publish directly without previewing the rendered block
Let Claude auto-select categories and tags Create taxonomy terms without checking for existing ones first
Set table header styles on <tr>, not <th> Apply background colours to <th> elements

Tip: Use a Reference Post to Anchor the Style

Giving Claude the URL of an existing post on your blog and asking it to match the styling is the fastest way to maintain visual consistency. The Word Embeddings post and the SingIDBot guide were both created this way, borrowing section card layout, banner colours, and code block styles from earlier posts in the series.

This article was generated with the assistance of Claude by Anthropic and posted via the WordPress MCP connector. ✨

Leave a comment