What This Automation Does
This n8n workflow automatically sorts blog posts by category on a WordPress site. It stops the need for manual sorting and reduces mistakes by assigning a single relevant category based on the post title.
The workflow fetches all posts, sends titles to AI for category selection, and updates posts with the chosen category, saving hours of manual work.
Tools and Services Used
- WordPress REST API: Provides access to blog posts and allows updating post categories.
- OpenAI API: Processes post titles to determine best category using a custom prompt.
- n8n Workflow Automation Platform: Links WordPress and OpenAI nodes and manages task automation.
Input → Process → Output
Inputs
- All existing WordPress posts retrieved via the WordPress node.
- Each post’s title text is input for AI categorization.
Processing Steps
- n8n fetches every post with WordPress API.
- The AI Agent node sends a prompt with post title to OpenAI.
- AI returns the single best category ID from a fixed category list.
- The workflow updates each post’s category in WordPress using the returned ID.
Output
- All WordPress posts have an updated primary category set accurately.
- The user saves over 3 hours weekly on manual post sorting.
Beginner Step-by-Step: Using This Workflow in n8n
Importing the Workflow
- Download the workflow file using the Download button on this page.
- Open the n8n editor you already use.
- Click on Import, then choose “Import from File” to add the workflow into n8n.
Configuring Credentials
- Add your WordPress API credentials in the WordPress nodes.
- Insert your OpenAI API key in the AI Agent node credentials.
- Check and update category IDs in the AI Agent prompt if changes apply.
Testing and Activation
- Run the workflow once using the Manual Trigger node “Execute Workflow” button to verify it works.
- Confirm categories update correctly in your WordPress admin panel.
- Activate the workflow within n8n to use it in production.
- Optionally set schedule or manual triggers as needed.
- Consider self-host n8n if running on your own server.
Common Issues and Fixes
401 Unauthorized Errors
Check WordPress API credentials in n8n. Make sure API keys have permission to access posts.
AI Agent Returns No or Wrong Category
Make sure AI prompt text is copied exactly. Verify OpenAI API key is active and valid.
Posts Not Updating
Double-check dynamic expressions used for postId and categories fields. IDs must match WordPress post data and AI output format.
Customization Ideas
- Change the category list in AI prompt to your own taxonomy.
- Limit how many posts run by adjusting the WordPress getAll node.
- Modify AI prompt to return category names if preferred and change update node mapping accordingly.
Summary of Benefits
✓ Saves time by automating post categorization.
✓ Reduces errors from manual sorting.
✓ Improves site navigation with consistent categories.
✓ Works fast on 80+ posts in minutes.
✓ Easy to run and customize inside n8n.
