WordPress powers 22.52% of the top one million websites as of December 2024, yet most teams still copy-paste content manually between tools. n8n, a Berlin-based workflow automation platform founded by Jan Oberhauser in 2019, connects WordPress REST API endpoints to 350+ apps without code. This guide shows exactly how to publish posts, update pages, and manage media programmatically — cutting publishing time by 80% for agencies and content teams.
Quick Answer: Connect n8n to WordPress using the REST API (enabled by default since WordPress 4.7, December 2016). Authenticate via Application Passwords (WordPress 5.6+) or JWT. Use n8n's HTTP Request node with endpoints like /wp/v2/posts for creating content, /wp/v2/media for uploads. Map fields from trigger apps (Airtable, Google Sheets, Webhooks) to WordPress post fields. Test, then activate the workflow.
Why Automate WordPress Publishing with n8n
Eliminate Manual Bottlenecks
Content teams waste 12+ hours weekly copying from Google Docs to WordPress, formatting, categorizing, and scheduling. n8n's visual node editor — built on Node.js and TypeScript — turns this into a single automated flow. Since its October 2019 launch, n8n has grown to 16,000+ community members by April 2021 because it handles complex logic (conditionals, loops, error handling) that Zapier and Make struggle with.
Own Your Data and Infrastructure
Unlike hosted tools, n8n runs self-hosted on your server (Docker, npm, Kubernetes) or via n8n Cloud. You control API keys, webhook URLs, and execution logs. With €55M Series B (March 2025) and $180M Series C (October 2025, $2.5B valuation), n8n GmbH invests heavily in security and enterprise features — critical for GDPR, HIPAA, or client confidentiality requirements.
Native WordPress REST API Support
WordPress REST API shipped in core version 4.7 (December 6, 2016). It exposes endpoints for posts, pages, media, taxonomies, users, and custom post types. n8n's HTTP Request node speaks this language natively — no custom plugins needed. You GET, POST, PUT, DELETE against /wp-json/wp/v2/ endpoints with standard JSON payloads.
Prerequisites and Authentication Setup
WordPress Side: Enable Application Passwords
- Update WordPress to 5.6+ (released December 8, 2020) — Application Passwords are built-in.
- Go to Users → Profile → Application Passwords. Name it "n8n-automation".
- Copy the generated 24-character password (shown once). Store in 1Password or Bitwarden.
- Verify REST API works: visit https://yoursite.com/wp-json/wp/v2/posts in browser — should return JSON.
n8n Side: Create Credentials
- In n8n, click Credentials → New Credential → "HTTP Header Auth".
- Name: "WordPress REST API". Header Name: "Authorization". Header Value: "Basic " + base64(username:app_password).
- Test with a GET request to /wp/v2/users/me — should return your user object.
Alternative: JWT Authentication
For multisite or stricter security, install the "JWT Authentication for WP REST API" plugin (200k+ active installs). Add define('JWT_AUTH_SECRET_KEY', 'your-64-char-secret'); to wp-config.php. In n8n, use "JWT" credential type: POST to /wp-json/jwt-auth/v1/token with username/password, store returned token, send as Bearer token in subsequent requests.
Build Your First Publishing Workflow
Trigger: New Record in Airtable
Real example: A marketing agency stores blog drafts in Airtable with fields: Title, Content (Markdown), Status, Category, Tags, Featured Image URL, Scheduled Date. Add an "n8n Trigger" view filtered to Status = "Ready to Publish". In n8n, add Airtable node → Trigger → New Record in View. Poll every 5 minutes (free tier) or use webhook for instant.
Transform: Map Fields to WordPress Schema
- Add "Set" node. Map Airtable fields to WordPress REST API payload:
- title: {{ $json.fields.Title }}
- content: {{ $json.fields.Content }} (convert Markdown to HTML via "Markdown" node first)
- status: "draft" or "publish" based on Scheduled Date
- categories: [{{ $json.fields.Category_ID }}] (fetch category IDs via separate GET /wp/v2/categories?search=name)
- tags: [{{ $json.fields.Tag_IDs }}]
- featured_media: (upload image first — see below)
- date: {{ $json.fields.Scheduled_Date }} (ISO 8601)
- Use "IF" node: if Scheduled Date > now, set status="future"; else status="publish".
Upload Featured Image via Media Endpoint
- Add HTTP Request node before post creation. Method: POST. URL: https://yoursite.com/wp-json/wp/v2/media.
- Headers: Authorization (from credentials), Content-Type: image/jpeg (or png/webp), Content-Disposition: attachment; filename="image.jpg".
- Binary Data: Enable "Send Binary Data", select Airtable image URL field.
- Response returns media ID. Pass to featured_media field in post creation.
Create or Update Post
- HTTP Request node: POST to /wp-json/wp/v2/posts (new) or PUT to /wp-json/wp/v2/posts/{{ $json.id }} (update).
- Include all mapped fields. Set "Response Format" to JSON.
- On success, capture returned post ID, permalink, date.
Sync Back to Airtable
Add Airtable "Update Record" node. Write back: WordPress Post ID, Permalink, Published Date, Status. Change Status to "Published". Add "Slack" node to notify #content channel with link.
Advanced Patterns: Taxonomies, Custom Fields, and ACF
Dynamic Category and Tag Creation
If Airtable category doesn't exist in WordPress, n8n can create it. Flow: Search /wp/v2/categories?search=name → if empty, POST to /wp/v2/categories with name/slug → use returned ID. Same for tags. Prevents "Category not found" errors on import.
Advanced Custom Fields (ACF) Integration
ACF PRO (1M+ sites) exposes custom fields via REST API when "Show in REST API" is enabled per field group. Payload includes acf object: { "acf": { "hero_text": "Welcome", "cta_button": "Buy Now" } }. In n8n, map Airtable long-text fields directly into acf object. Test with GET /wp/v2/posts/123 to see exact structure.
WooCommerce Product Publishing
Same pattern works for /wp/v2/products endpoints. Map SKU, price, stock_status, attributes, gallery images. Use n8n's "Split In Batches" node to process 500-row CSV exports from ERP systems — throttling to 10 concurrent requests to avoid 429 rate limits.
Comparison: n8n vs Zapier vs Make vs Custom Code
Choosing the right automation layer depends on volume, complexity, and compliance needs. Below compares four approaches for WordPress publishing at scale.
All tools connect to WordPress REST API, but differ in hosting model, pricing scaling, and developer experience.
| Factor | n8n (Self-Hosted) | n8n Cloud | Zapier | Make (formerly Integromat) |
|---|---|---|---|---|
| Monthly Cost (10k executions) | $0 (server only) | $50 Starter / $200 Pro | $299 Team / $599 Professional | $29 Core / $99 Pro |
| WordPress Nodes | HTTP Request (full control) | HTTP Request + Community nodes | Native WordPress app (limited endpoints) | Native WordPress app (good coverage) |
| Custom Logic (JS/Python) | Full Code node support | Full Code node support | Code by Zapier (limited) | Functions (limited) |
| Data Residency | Your server / country | EU (Frankfurt) or US | US only | EU (Germany) or US |
| Rate Limit Handling | Custom retry/backoff logic | Built-in retry policies | Automatic, opaque | Configurable |
| Version Control | Git (workflows as JSON) | Git sync (Pro+) | None | Partial (scenarios JSON) |
| Active Community (2025) | 16,000+ (Apr 2021) → 100k+ | Same | 2M+ users | 500k+ users |
Common Mistakes and Pro Fixes
Mistake 1: Hardcoding Category/Tag IDs
Why It Hurts: IDs differ across dev/staging/prod. Workflow breaks on deploy.
Fix: Always search by slug/name at runtime: GET /wp/v2/categories?slug=my-category → use returned ID. Cache results in n8n's built-in Redis or static data node for 1 hour to reduce API calls.
Mistake 2: Ignoring Rate Limits and 429 Errors
Why It Hurts: WordPress defaults to 100 requests/minute for authenticated users. Bulk imports hit 429, fail silently.
Fix: Add "Throttle" node (max 30/min). Implement exponential backoff in "Error Trigger" workflow: wait 60s, retry 3x, then alert via Slack/email. Monitor via n8n execution logs.
Mistake 3: Storing Credentials in Workflow JSON
Why It Hurts: Exported workflows leak passwords. Git commits expose secrets.
Fix: Use n8n Credentials system exclusively. Reference by name: {{ $credentials.wordpressRestApi }}. Rotate Application Passwords quarterly.
Mistake 4: Not Handling HTML/Markdown Conversion
Why It Hurts: WordPress expects HTML. Markdown renders as raw text. ACF wysiwyg fields need sanitized HTML.
Fix: Use n8n "Markdown" node (remark.js) or "HTML" node (DOMPurify) before payload assembly. Strip dangerous tags: script, iframe, style unless explicitly allowed.
Mistake 5: Skipping Idempotency Keys
Why It Hurts: Re-running workflow creates duplicate posts. Webhook retries double-publish.
Fix: Generate deterministic ID from source record (e.g., airtable_record_id). Before POST, GET /wp/v2/posts?meta_key=source_id&meta_value=rec123. If exists, PUT update; else POST create. Store mapping in n8n Key-Value store.
Pro Tips
- Use n8n's "Merge" node to combine data from Airtable, WordPress (existing categories), and external APIs (Unsplash for images) in one flow.
- Enable WordPress "application-passwords" REST API namespace for granular revocation: delete single app password without affecting others.
- Schedule heavy imports (1000+ posts) via n8n Cron node at 2 AM local time — avoids user-facing slowness.
- Test with WordPress "WP REST API Log" plugin (debug bar) to inspect incoming requests/headers.
- Version-control workflows: n8n CLI exports workflow JSON. Commit to Git. CI/CD deploys via n8n import:workflows command.
FAQ
What is the WordPress REST API and when was it added to core?
The WordPress REST API provides programmatic access to posts, pages, media, taxonomies, and users via standard HTTP endpoints. It was merged into WordPress core in version 4.7, released December 6, 2016. The base route is /wp-json/wp/v2/ and returns JSON by default.
How does n8n authentication differ from Zapier for WordPress?
n8n uses HTTP Header Auth (Basic Auth with Application Passwords) or JWT tokens you manage directly. Zapier uses OAuth2 flow handled on their servers — you never see the token. n8n gives full control over credential rotation, scoping, and audit logs; Zapier abstracts this but limits endpoint coverage to their pre-built actions.
Can I publish custom post types and ACF fields with n8n?
Yes. Custom post types registered with 'show_in_rest' => true appear at /wp/v2/your-cpt-slug. ACF fields with "Show in REST API" enabled appear in the acf object on POST/PUT requests. Map n8n Set node fields directly into the acf property. Test first with GET to confirm field keys.
Why do my scheduled posts publish immediately instead of at the future date?
WordPress requires status="future" AND a date field in ISO 8601 format (YYYY-MM-DDTHH:MM:SS) that is in the future relative to site timezone. Check: Settings → General → Timezone matches your n8n workflow timezone. Use n8n DateTime node to format: {{ $now.plus({days: 1}).toISO() }}.
What happens to my workflows if n8n Cloud shuts down or changes pricing?
n8n is source-available (Sustainable Use License). You can export all workflows as JSON and self-host on your own Docker/Kubernetes infrastructure at any time. The community edition has no execution limits. Many teams start on Cloud and migrate to self-hosted when volume exceeds $200/mo Pro plan.
Conclusion
Automating WordPress publishing with n8n transforms content operations from manual drudgery into a reliable, auditable pipeline. By leveraging WordPress REST API (core since 2016) and n8n's visual Node.js-based editor (350+ integrations, 100k+ community), you eliminate copy-paste errors, enforce editorial standards, and scale to thousands of posts monthly. The self-hosted option keeps data sovereign — critical for agencies, enterprises, and regulated industries. Start with one workflow: Airtable → WordPress. Measure time saved. Expand to WooCommerce, multilingual (WPML), or headless frontends.
- Authentication: Use WordPress 5.6+ Application Passwords with n8n HTTP Header Auth — simplest, most secure.
- Idempotency: Always check existing content via source ID meta field before create/update.
- Observability: Log every execution to Slack/Email; monitor 429 rates; version-control workflow JSON in Git.
0 comments:
Post a Comment