Opening Problem Statement
Meet Sarah, a content manager at a growing digital marketing agency. She spends hours each week manually transferring AI-generated blog posts stored in Airtable into her company’s WordPress website. Not only does she have to copy and paste markdown content and convert it to HTML, but she also painstakingly uploads and sets the featured images for each post. This repetitive, error-prone process wastes her valuable time and often leads to formatting inconsistencies and delayed publishing schedules.
Sarah loses approximately 5-7 hours weekly in managing this workflow, leading to frustration and missed opportunities to boost online presence on schedule. Manual mistakes in image uploads and post formatting mean extra rounds of edits, costing even more time and money.
This is where automation with n8n comes in. By integrating Airtable with WordPress via n8n, Sarah can automatically fetch the AI-generated blog posts marked as “To Post”, convert the content from markdown to HTML, upload the post and its featured image, and finally update Airtable status—all without lifting a finger.
What This Automation Does
This n8n workflow automates the publishing of AI-generated blog content from Airtable to a WordPress website, complete with featured images. Specifically, it:
- Fetches blog posts marked “To Post” from Airtable.
- Filters out incomplete posts to ensure only valid content proceeds.
- Transforms markdown blog content into HTML format ready for WordPress.
- Publishes the blog post as a draft on WordPress with title and content.
- Searches and downloads a relevant featured image using the Pexels API based on the blog’s keyword.
- Uploads the image to WordPress media and sets it as the post’s featured image.
- Updates Airtable to mark the post status as “Posted” after successful publishing.
This automation saves Sarah upwards of 5 hours per week, eliminates manual errors, and keeps her blog posting process consistent and timely.
Prerequisites ⚙️
- n8n account to create and run workflows.
- Airtable account with a base that includes a table for AI-generated blog posts with columns: Keyword, Title, Blog content (in markdown), and a Status column to track publishing stages.
- WordPress website with REST API access and credentials for API authentication to post blogs and upload media.
- Pexels API key for fetching relevant blog images.
Optional: Self-host n8n for full control and scalability (see Hostinger n8n hosting).
Step-by-Step Guide to Automate WordPress Blog Posting
Step 1: Set up the Schedule Trigger to Run Periodically ⏱️
In n8n, add the Schedule Trigger node.
- Navigate to the node panel → Search and select Schedule Trigger.
- Configure the interval (default runs every minute, adjust for your needs).
- This node starts the workflow automatically at your set intervals.
- Select your Airtable base and table where blogs are stored.
- Use the filter formula:
SEARCH("To Post", {Status})to get only posts needing publishing.
Expected outcome: Workflow runs regularly without manual start.
Common mistake: Forgetting to enable the workflow after setup.
Step 2: Fetch Blog Posts from Airtable Marked “To Post” 📊
Add the Airtable node with operation set to “Search”.
Expected outcome: Gets up to 3 blog posts ready to publish.
Common mistake: Incorrect base/table selection causing empty results.
Step 3: Filter Out Empty Blog Content
Use the Filter node to check that the “Blog Post” field exists and is not empty.
Condition example:
{
"leftValue": "={{ $json['Blog Post'] }}",
"operator": "exists"
}> Only posts with content proceed.
Step 4: Prepare Data Fields with the Set Node
Add the Set node to rename and organize fields.
- Assign values like
id,Title,Keyword, and remove title from the raw markdown blog post to create a cleanBlog Body. - Use this JavaScript expression:
= {{$json["Blog Post"].replace($json["Title"],'')}}. - Map the blog title and HTML content using expressions
= {{$json.Title}}and= {{$json['Blog Body']}}. - Set the post status as
draftto review before going live. - Use GET method with URL format:
https://api.pexels.com/v1/search?query=Keyword&per_page=1&width=1200&height=675&format=webp. - Authorize using your Pexels API key in headers.
- Set headers for content-disposition and content-type dynamically.
- Use credentials for WordPress API authentication.
- Change Post Status from Draft to Publish
In the WordPress node, changestatusfromdrafttopublishfor immediate live posts. - Add Multiple Images per Post
Modify the workflow to loop fetching and uploading multiple images using Pexels API query variations and update featured_image accordingly. - Use Different Image Sources
Replace the Pexels API HTTP Request node with another image provider API node like Unsplash. - Update Additional WordPress Post Fields
In the WordPress node, include tags or categories dynamically from Airtable columns. - Limit Posts Per Run
Adjust the Airtable “limit” parameter to control how many posts are processed each workflow run. - Verify Airtable base columns and filter formula for “To Post” status.
- Test WordPress REST API credentials and post creation with a test blog.
- Test Pexels API key by fetching an image manually.
- Run workflow manually in n8n with debug enabled to track data flow.
- Backup Airtable data before initial runs.
Expected outcome: Clean, structured data passing to next steps.
Step 5: Convert Markdown Blog Content to HTML
Use the Markdown node to convert Blog Body from markdown to HTML content.
Set mode to “markdownToHtml” and destination key to “Blog Body” for later use.
Expected outcome: The blog content is ready for WordPress format.
Step 6: Publish the Blog Post as Draft on WordPress
Add the WordPress node to create a new post.
Expected outcome: A blog post draft created in WordPress.
Step 7: Fetch a Relevant Image Using Pexels API
Add the HTTP Request node to call the Pexels API.
Expected outcome: Returns top image data matching the blog keyword.
Step 8: Download the Selected Image
Use another HTTP Request node configured to GET the image URL from the previous node’s response with response format set to “file”.
Expected outcome: Image file is downloaded ready for upload.
Step 9: Upload the Image to WordPress Media Library
Add the HTTP Request node to POST the binary image data to WordPress media endpoint /wp-json/wp/v2/media.
Expected outcome: Image file uploads successfully into WordPress.
Step 10: Set the Uploaded Image as Featured Image for the Post
Add another HTTP Request node to update the post with the featured_media ID returned from the image upload.
Expected outcome: Post now shows the downloaded image as the featured image.
Step 11: Update the Airtable Record Status to “Posted”
Add another Airtable node to update the blog’s status back in Airtable.
Map the record ID with status set to “Posted” so it doesn’t get reposted.
Expected outcome: Airtable accurately reflects published posts.
Customizations ✏️
Troubleshooting 🔧
Problem: “WordPress API returns 401 Unauthorized”
Cause: Incorrect WordPress API credentials or lack of permissions.
Solution: Recheck API user password, enable application password in WordPress, and update credentials in n8n node.
Problem: “Image upload fails or returns invalid response”
Cause: Header misconfiguration or binary data not sent properly.
Solution: Ensure content-type and content-disposition headers are correct and binary data field is set to image data.
Problem: “Airtable records not updating”r>Cause: Mismatched record IDs or incorrect mapping.
Solution: Verify that Airtable record IDs are correctly passed from previous nodes and mapped to the update node.
Pre-Production Checklist ✅
Deployment Guide
Activate the workflow in n8n after completing setup and testing.
Monitor workflow executions in the n8n dashboard to catch any errors or interruptions.
Schedule the trigger at your preferred publishing frequency (e.g., daily or multiple times per day).
FAQs
Q: Can I use Google Sheets instead of Airtable?
A: This workflow uses Airtable’s search and update API features extensively. Google Sheets would require a different setup but could be integrated with n8n similarly.
Q: Does uploading images consume a lot of API credits?
A: Pexels API has limits on free and paid plans. Monitor your usage within the API dashboard.
Q: Is my WordPress data secure in this automation?
A: API credentials are stored securely in n8n, but always follow best security practices and limit API permissions smartly.
Conclusion
By following this detailed guide, you’ve automated Sarah’s tedious blog posting workflow, turning hours of manual work into a seamless automated process. Now, AI-generated content from Airtable is effortlessly published as WordPress draft posts, complete with relevant featured images, and Airtable statuses are updated automatically. This automation can save you at least 5 hours per week while reducing errors and improving consistency.
Next, consider expanding this workflow to schedule posts automatically, integrate social media posting, or generate SEO meta descriptions using AI nodes.
Happy automating!