WordPress + OpenAI: clean categories for every post
Uncategorized posts quietly wreck a WordPress site. Your archives get messy, your “top category” report becomes meaningless, and someone ends up doing a late-night cleanup sprint before the next campaign.
This is exactly the kind of WordPress category automation that saves content managers the most time, but marketing leads and site owners feel the pain too. You will stop chasing old posts, and categories will stay consistent without constant babysitting.
This workflow pulls uncategorized posts, has OpenAI decide the best fit from your predefined categories, then updates WordPress automatically. Below, you’ll see how it runs, what you need, and the real-world time difference.
How This Automation Works
The full n8n workflow, from trigger to final output:
n8n Workflow Template: WordPress + OpenAI: clean categories for every post
flowchart LR
subgraph sg0["Manual Run Flow"]
direction LR
n0@{ icon: "mdi:play-circle", form: "rounded", label: "Manual Run Trigger", pos: "b", h: 48 }
n1["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/wordpress.svg' width='40' height='40' /></div><br/>Update WP Categories"]
n2["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/wordpress.svg' width='40' height='40' /></div><br/>Retrieve WP Articles"]
n3@{ icon: "mdi:brain", form: "rounded", label: "OpenAI Chat Engine", pos: "b", h: 48 }
n4@{ icon: "mdi:robot", form: "rounded", label: "Category Decision Agent", pos: "b", h: 48 }
n4 --> n1
n3 -.-> n4
n2 --> n4
n0 --> n2
end
%% Styling
classDef trigger fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
classDef ai fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
classDef aiModel fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
classDef decision fill:#fff8e1,stroke:#f9a825,stroke-width:2px
classDef database fill:#fce4ec,stroke:#c2185b,stroke-width:2px
classDef api fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef code fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
classDef disabled stroke-dasharray: 5 5,opacity: 0.5
class n0 trigger
class n4 ai
class n3 aiModel
classDef customIcon fill:none,stroke:none
class n1,n2 customIcon
The Problem: Uncategorized Posts Break Your Content System
Uncategorized posts don’t just look sloppy. They create small, constant friction across your whole publishing process. Someone publishes in a hurry, forgets to assign a category, and now your blog navigation is off, your internal search and filters get weaker, and your analytics become harder to trust. Worse, the backlog grows silently. A dozen posts becomes 40, then 100, and fixing it later means opening each post, guessing the right category, and hoping you didn’t miss something obvious in the title.
It adds up fast. Here’s where it breaks down in day-to-day work.
- Cleaning up categories turns into a recurring chore that steals an hour when you least have it.
- Two people categorize differently, so “insights” and “thought leadership” become duplicates in spirit.
- Reporting gets fuzzy because “Uncategorized” becomes one of your biggest “topics.”
- Old content stays underused because it’s harder to find, group, and refresh.
The Solution: AI Auto-Categorization Inside WordPress
This workflow connects to your WordPress site, finds posts that are missing categories, and fixes them in bulk. It starts by retrieving uncategorized articles from WordPress. Then an AI agent reads each post title and matches it to the category list you’ve already defined in WordPress (using your category IDs so the workflow updates the right thing, every time). Once a match is decided, n8n updates the post in WordPress with the correct category. You get cleaner archives, more consistent reporting, and a publishing process that doesn’t rely on someone remembering “one more step.” Honestly, it’s the kind of automation that makes your blog feel maintained even when things get busy.
The workflow starts with a manual run in n8n, which is perfect for safe testing. From there, WordPress posts are pulled in, OpenAI makes a category decision using your rules, and WordPress gets updated with the chosen category IDs. The end result is simple: fewer uncategorized posts, and far less manual cleanup.
What You Get: Automation vs. Results
| What This Workflow Automates | Results You’ll Get |
|---|---|
|
|
Example: What This Looks Like
Say you have 60 uncategorized posts after a quarter of publishing. Manually, even a quick “open post, pick category, update” takes about 2 minutes each, so you’re staring at roughly 2 hours of cleanup (and that’s if you don’t second-guess anything). With this workflow, you trigger the run in n8n, the AI assigns categories in bulk, and WordPress gets updated automatically. You’ll spend maybe 10 minutes reviewing a sample of results, then move on.
What You’ll Need
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- WordPress for retrieving and updating posts.
- OpenAI to decide categories from titles.
- OpenAI API key (get it from your OpenAI account dashboard).
Skill level: Beginner. You’ll paste API keys, connect WordPress credentials, and edit a category list in the AI prompt.
Don’t want to set this up yourself? Talk to an automation expert (free 15-minute consultation).
How It Works
Manual run kicks it off. You start the workflow when you’re ready, which is ideal for testing on a small batch before letting it rip on your backlog.
WordPress pulls the right posts. n8n retrieves articles that are currently uncategorized, so you’re only touching the content that needs attention.
OpenAI makes a category decision. The AI agent evaluates the post title against your predefined WordPress categories (using the category IDs you provide). If you want tighter control, you can tweak the prompt so it follows your exact rules, not generic “blog best practices.”
WordPress gets updated automatically. The workflow applies the chosen category to each post, so your site structure and reporting clean up in the background.
You can easily modify category logic to allow multiple categories or add tag generation based on your needs. See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Manual Trigger
This workflow starts manually so you can test categorization before scheduling or scaling.
- Add the Manual Run Trigger node as your starting point.
- Leave all Manual Run Trigger fields at their defaults since no parameters are required.
- Confirm the connection from Manual Run Trigger to Retrieve WP Articles.
Step 2: Connect WordPress
Retrieve posts so the AI can evaluate each title and assign a category.
- Add the Retrieve WP Articles node.
- Set Operation to
getAll. - Enable Return All by setting it to
true. - Credential Required: Connect your wordpressApi credentials in Retrieve WP Articles.
Flowpast Branding is a sticky note for documentation and can remain as-is.
Step 3: Set Up the AI Decision Agent
The AI agent analyzes each post title and returns a single category ID.
- Add the Category Decision Agent node and connect it after Retrieve WP Articles.
- Set Prompt Type to
define. - Set Text to the full prompt provided in the workflow, including the expression
{{ $json.title.rendered }}. - Ensure OpenAI Chat Engine is connected as the language model for Category Decision Agent via the AI Language Model connection.
- Credential Required: Connect your openAiApi credentials in OpenAI Chat Engine (credentials are applied at the parent model, not the agent node).
Step 4: Configure the WordPress Update Action
Apply the category ID output from the agent back to the WordPress post.
- Add the Update WP Categories node and connect it after Category Decision Agent.
- Set Operation to
update. - Set Post ID to
={{ $('Retrieve WP Articles').item.json.id }}. - Under Update Fields, set Categories to
={{ $json.output }}. - Credential Required: Connect your wordpressApi credentials in Update WP Categories.
⚠️ Common Pitfall: If the agent outputs anything other than a single numeric category ID, WordPress will reject the update. Keep the prompt exactly as provided.
Step 5: Test and Activate Your Workflow
Validate that categories update correctly before turning the workflow on.
- Click Execute Workflow to run Manual Run Trigger and process your posts.
- Confirm that Category Decision Agent outputs a single number per post and that Update WP Categories updates the post categories.
- Open a sample WordPress post to verify the category assignment matches the AI output.
- When you’re satisfied with the results, toggle the workflow Active to enable production use.
Common Gotchas
- WordPress credentials can expire or need specific permissions. If things break, check your n8n Credentials page and confirm the WordPress user is an admin (or has edit rights for posts) first.
- If you’re processing a big backlog, OpenAI responses and WordPress updates can take longer than you expect. If downstream nodes fail or return empty data, slow it down by batching fewer posts per run.
- Default AI prompts are generic. Add your category list, category IDs, and a couple “edge case” examples early, or you will spend time correcting perfectly fluent but wrong assignments.
Frequently Asked Questions
About 30 minutes if your WordPress and OpenAI accounts are ready.
No. You’ll connect your WordPress credentials and paste your category IDs into the AI prompt.
Yes. n8n has a free self-hosted option and a free trial on n8n Cloud. Cloud plans start at $20/month for higher volume. You’ll also need to factor in OpenAI API costs, which are usually a few cents for batches of titles.
Two options: n8n Cloud (managed, easiest setup) or self-hosting on a VPS. For self-hosting, Hostinger VPS is affordable and handles n8n well. Self-hosting gives you unlimited executions but requires basic server management.
Yes, but test it carefully. You’ll adjust the instructions in the Category Decision Agent so it can return more than one category ID when a title clearly spans topics. Some teams also add a rule like “always pick one primary category” to avoid over-tagging. After that, make sure the WordPress update step is set to apply an array of category IDs, not a single value.
Usually it’s credentials or permissions. Recheck the WordPress credential in n8n and confirm the user can edit posts, not just view them. If it still fails, your site may block XML-RPC/REST requests or require application passwords; enabling the right authentication method on WordPress typically fixes it.
Plenty for most small sites. If you run it in batches of 20–50 posts, it stays stable and easy to review, and you can repeat runs until the backlog is gone. On n8n Cloud, your limit is based on monthly executions; if you self-host, you’re mostly limited by your server and how fast you want to send requests to WordPress and OpenAI.
Often, yes, because n8n handles more complex logic without you paying extra for every branch and filter. The AI agent pattern is also more flexible, so you can add rules like “never use Category X” or “map these keywords to Category Y” without fighting the tool. Another win is self-hosting, which means you can run bulk cleanup without worrying as much about task limits. Zapier or Make can still be fine for simpler setups, especially if you only want to categorize new posts one at a time. Talk to an automation expert if you want help choosing.
Once your categories are enforced automatically, the whole content system feels calmer. Set it up, run it on your backlog, and keep publishing without the cleanup debt.
Need Help Setting This Up?
Our automation experts can build and customize this workflow for your specific needs. Free 15-minute consultation—no commitment required.